Jump to content

XML Dom - Search


twsowerby

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/85471-xml-dom-search/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.