SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: DOM Problem
-
May 23, 2003, 06:10 #1
- Join Date
- Mar 2001
- Location
- Tampa, FL
- Posts
- 376
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
DOM Problem
Well PHP keeps tearing everything up in the DOM area to gain full DOM2 Compliance and I am stuck.
I am trying to access the content of a child node and the function get_content() is aparently deprecated and non-DOM compliant, so how am I supposed to access the content of the child node?
-
May 23, 2003, 06:46 #2
- Join Date
- Jun 2002
- Location
- Brazil
- Posts
- 149
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try to use $content = $dom_doc->dump_node($node); might it works.
Last edited by marcoBR; May 24, 2003 at 11:22.
-
May 23, 2003, 08:13 #3
- Join Date
- Mar 2001
- Location
- Tampa, FL
- Posts
- 376
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I figured out what was happening, I forgot text nodes are a separate node itself so I had to iterate one more time to get to it, which is very annoying.
How could I write a get_content equivelent since its being deprecated?
this is my quick stab at it, let me know if I am wrong...
PHP Code:function get_content(&$node) {
$content = $node->child_nodes();
return $content[0];
}
-
May 23, 2003, 14:03 #4
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just a wild guess though if your script doesn't work; try this slight alteration ?
PHP Code:function get_content(&$node) {
$content = $node->child_nodes();
return $content[1];
}
-
May 24, 2003, 00:25 #5
- Join Date
- Mar 2001
- Location
- Tampa, FL
- Posts
- 376
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
its actually a return $content[0]->content; so I messed up there anyway.
Does anyone know if someone has written a DOM wrapper class to give a common interface to DOM? By this I mean a object to contain everything, resulting in much less code.
Bookmarks