Malcolmhire2001 Posted January 16, 2007 Share Posted January 16, 2007 hello,I have created a form for information to be entered i am then posting this form to this page:[code]!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><body><?php $type = $_POST['type']; $xml = simplexml_load_file('holidays.xml'); echo "<B>Using direct method...</B><BR />"; $names = $xml->xpath('/holidays/holiday[type= "$type"]'); foreach($names as $name) { echo "Found {$name->type}<BR />"; } echo "<BR />";?></body></html>[/code]and storing the POST as a variable, the variable is then suppose to be the criteria for the XPath Search, but the search does not bring up any results. Only the Text that is echoed out which is: "Using direct method..."if anyone could helpThanks, Mal Link to comment https://forums.phpfreaks.com/topic/34356-php-searching-xml-with-xpath-help-needed/ Share on other sites More sharing options...
effigy Posted January 16, 2007 Share Posted January 16, 2007 Variables do not interpolate in single quotes; try this:[code]$names = $xml->xpath('/holidays/holiday[type= "' . $type . '"]');[/code] Link to comment https://forums.phpfreaks.com/topic/34356-php-searching-xml-with-xpath-help-needed/#findComment-161701 Share on other sites More sharing options...
Malcolmhire2001 Posted January 16, 2007 Author Share Posted January 16, 2007 thats great that worked straight awaythank you very much you have saved me alot of time.thanks, Mal Link to comment https://forums.phpfreaks.com/topic/34356-php-searching-xml-with-xpath-help-needed/#findComment-161707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.