twsowerby Posted January 11, 2008 Share Posted January 11, 2008 Hi, I've got this code which returns all the data in an XML file: <?php $doc = new DOMDocument(); $doc->load( 'filmReviews.xml' ); $films = $doc->getElementsByTagName( "film" ); foreach( $films as $film ) { $titles = $film->getElementsByTagName( "title" ); $title = $titles->item(0)->nodeValue; $dates = $film->getElementsByTagName( "date" ); $date = $dates->item(0)->nodeValue; $notes = $film->getElementsByTagName( "notes" ); $note = $notes->item(0)->nodeValue; echo "$title - $date \n <br /><br />$note\n<br /><br />"; } ?> I need to be able to use a form to search the XML. For example, I would like to be able to search by film title. I'm not entirely sure how to get this to work as I have very limited experience with XML. Any help would be great! Thanks, Tom Quote Link to comment https://forums.phpfreaks.com/topic/85471-xml-dom-search/ Share on other sites More sharing options...
priti Posted January 11, 2008 Share Posted January 11, 2008 The standard way for searching through XML documents for particular nodes is XPath.Read below article. http://php5.bitflux.org/xmloncrack/slide_51.php Regards Quote Link to comment https://forums.phpfreaks.com/topic/85471-xml-dom-search/#findComment-436364 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.