Hello,
I have an issue that I cannot seem to resolve using XML and PHP.
Given:
The XML
http://www.aagrating.com/19space.xml
The XSL
http://www.aagrating.com/format.xsl
The CSS
http://www.aagrating.com/table.css
Given this setup I would like to be able to filter my data given a PHP variable (i.e. form submits, loads XML and filters based off of user input). I can use xpath to output the format to a table correctly, but when I attempt to set a variable for XPath it locks up.
the php script:
http://www.aagrating.com/xmlTest.txt
I have attempted to use "$myVar", '$myVar' " '+myVar+' ", but I cannot find the correct syntax. Is this even possible? Any thoughts?
Thanks in advance!
-thom
Using a PHP variable to filter XML
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the original phptry
Code: Select all
<?php
echo "<html><head>";
echo "<title>Untitled Document</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"table.css\" />";
echo "</head>";
$s = simplexml_load_file('19space.xml');
$myVar="19W4";
$bar = $s->xpath('/Root/product[type="$myVar"]');
print $bar;
foreach($bar as $type) {
echo "Found {$type->type} <br />";
}
echo "<body></body></html>";
?>Code: Select all
<?php
echo "<html><head>";
echo "<title>Untitled Document</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"table.css\" />";
echo "</head>";
$s = simplexml_load_file('19space.xml');
$myVar="19W4";
$bar = $s->xpath('/Root/product[type="'.$myVar.'"]');
print $bar;
foreach($bar as $type) {
echo "Found {$type->type} <br />";
}
echo "<body></body></html>";
?>-
vietboy505
- Forum Commoner
- Posts: 53
- Joined: Wed Feb 22, 2006 9:30 am