Phil Weighill-Smith wrote:
In this case, why not use:
...(root, "child::[EMAIL PROTECTED]'\"value'/@name");
Because the xpath is created dynamically. And even though a " quote can be detected first, it still does not help if both a " and a ' is contained in the value.
Okay, I found the answer to my question in the W3C XPath mailing list archive.
It is impossible to escape a (double)quote character in XPath 1.0.
The workaround is to use concat.
http://lists.w3.org/Archives/Public/www-xpath-comments/2004JanMar/0011.html
How do I escape special characters in xpath to match attribute values?
For example
Document doc = new DocumentImpl();
Element root = doc.createElement("root");
doc.appendChild(root);
Element child = doc.createElement("element");
child.setAttribute("name","\"value");
root.appendChild(child);
Node node = XPathAPI.selectSingleNode(root,"child::[EMAIL PROTECTED]""value\"]/@name");
The node will be null, so this is not the right way. What is?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]