I seem to be hitting a wall here. I have the need to run an XPath query
on strings that may contain quotes, apostrophes or both. Going through
google turned up some interesting information, but nothing that solved
my issue.

An example of what I am trying to do is as follows:

$query = '\'foo"bar';
$xpath->query('/[EMAIL PROTECTED]"'.$query.'"]')->item(0);

This produces these warnings and errors:

Warning: DOMXPath::query() [function.DOMXPath-query]: Invalid predicate
Warning: DOMXPath::query() [function.DOMXPath-query]: Invalid expression
Fatal error: Call to a member function item() on a non-object

I've tried to escape the characters in the query, but that seems to be
illegal for XPath from what I've read. I've tried turning the quotes
into " and apostrophes into ' but it appears that XPath
requires that the data be unencoded to work.

I've seen reference to using XSLT to set XPath variables instead, but I
don't understand how to do implement this.

I would really appreciate any examples on what people have done to get
around this issue, if any one has at all.

Regards,

Adam.

--
Adam Randall <[EMAIL PROTECTED]>
(206) 285-8080
100 West Harrison
North Tower, Suite 300
Seattle, WA
98119

"Engineers like to solve problems. If there are no problems handily
available, they will create their own problems." - Dilbert

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to