PHP - XML xpath function - Search for value

gzowner

New Member
I've read various post and tried various solutions, but until now, I don't know how to use the xpath function for my goal.I've a XML file, that looks like this:\[code\]<?xml version="1.0" encoding="iso-8859-1"?><document>History</document><document>History Paragraph 1 until 7</document><document>Other documents...</document>\[/code\]I need an PHP script that finds out if a my XML file contains a variable.Example (how it should function, but this is not a working script):\[code\]function xmlcontain($docname){//Load XML file$xmlfile = 'users/'.$_SESSION['usr'].'/downloaded.xml'; $xml = XMLload->($xmlfile);//Whether the XML file contains an element named 'document', with the value of $docnameif($xml contains $xml->'/document'->value[$docname]){ //If it does contain... return 1;} else { //If it doesn't... return 0;} }\[/code\]Notice that my XML file is located in '/users/[username]/downloaded.xml', while my script is 'download.php'.I also want that if I use the function to search for "History", and when there isn't a document "History", but "History Paragraph 1 until 7" is there, it will returns 0. Because "History Paragraph 1 until 7" does contain "History", but it isn't equal to "History"Please help,Thank you,IsaiahP.S. I hope I was clear enough.
 
Back
Top