GET syntax in xpath
Posted
by
David Doria
on Stack Overflow
See other posts from Stack Overflow
or by David Doria
Published on 2010-12-27T23:47:06Z
Indexed on
2010/12/27
23:54 UTC
Read the original article
Hit count: 333
I am trying to use a parameter that I pass to the page in an xpath query. This works properly (hard coded):
<?php
$xml = simplexml_load_file("bookstore.xml");
$res = $xml->xpath("/bookstore/book[title = 'Everyday Italian']");
echo $res[0]->author
?>
but I pass the parameter with:
bookdetails.php?title="Everyday Italian"
and then do:
<?php
$xml = simplexml_load_file("bookstore.xml");
$res = $xml->xpath("/bookstore/book[title = $_GET['title']]");
echo $res[0]->author
?>
I get a 500 error.
Any thoughts?
Thanks,
David
© Stack Overflow or respective owner