TheJoey Posted May 14, 2010 Share Posted May 14, 2010 <?php $xmlDoc = new DOMDocument(); $xmlDoc->load("abc.xml"); echo '<form method="get"> search: <input type="text" name="search" /><br /> <input type="submit" value="Submit" /> </form>'; // We need to validate our document before refering to the id $xmldoc->validateOnParse = true; function $id { } $xmldoc->getElementByName('$id')->tagName . "\n"; print $xmlDoc->saveXML(); ?> just now sure how to right a function that would search the xml file which contains. <books> <book> <author>Jack Herrington</author> <title>PHP Hacks</title> <publisher>O'Reilly</publisher> </book> </books> Quote Link to comment https://forums.phpfreaks.com/topic/201706-php-dom-troubles/ Share on other sites More sharing options...
TheJoey Posted May 16, 2010 Author Share Posted May 16, 2010 <?php $xmlDom = new DOMDocument(); $xmlDom->load("searchcontents.xml"); $xmldom->validateOnParse = true; $variable =$argv[1]; $results =$xmlDom->getElementsByTagname($variable); if $findresult = $variable { foreach ($findresults as $result) { // childNodes holds the result values $text_nodes = $result->childNodes; foreach ($text_nodes as $text) { print $text->nodeValue . "\n"; } } } print $xmlDom->saveXML(); ?> ive changed my code to this but still cant get it to display all results that match <books> <book> <author>Jack Herrington</author> <title>PHP Hacks</title> <publisher>O'Reilly</publisher> </book> <book> <author>Jack Herrington</author> <title>PHP </title> <publisher>booky</publisher> </book> </books> so if i try to search "jack" it will display all results with jack in it Quote Link to comment https://forums.phpfreaks.com/topic/201706-php-dom-troubles/#findComment-1059030 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.