how to get one item out of xml with php?

bocaj812

New member
I need to figure out how to select one item out of an xml document with multiple items. Then from that one item, set each child node as a php variable. I am having trouble selecting one item to get the child nodes. right now all i can do is print child nodes from all items. I only want to assign variables to the child nodes of one variable.
 
If you know or are willing to learn XPath (it's easy, don't worry), it's pretty much the best tool for the job.

http://us2.php.net/manual/en/class.domxpath.php

You can also do this with the SimpleXML library, which is easier:
http://us2.php.net/manual/en/book.simplexml.php

SimpleXML will let you either use XPath or walk through a big object derived from the source file until you find what you want.
 
Back
Top