flashdomm Posted June 17, 2010 Share Posted June 17, 2010 Hi guys, I am trying to figure how to use this code when you have nodes deeper than 1 child element. Here's the code from PHP Manual: <?php $doc = new DOMDocument; $doc->load('book.xml'); $book = $doc->documentElement; // we retrieve the chapter and remove it from the book $chapter = $book->getElementsByTagName('chapter')->item(0); $oldchapter = $book->removeChild($chapter); echo $doc->saveXML(); ?> <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <book id="listing"> <title>My lists</title> <chapter>blah</chapter> </book> http://www.php.net/manual/en/domnode.removechild.php I am having trouble understanding third line. What does "documentElement" link to? What can I do if node in question is within more than 1 element node ?? I spend ages trying to figure this out but not getting anywhere, I would really really appreciate any help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.