Jump to content

PHP Searching XML with XPath Help Needed!


Malcolmhire2001

Recommended Posts

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 help

Thanks, Mal
Link to comment
https://forums.phpfreaks.com/topic/34356-php-searching-xml-with-xpath-help-needed/
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.