单引号的XPATH查询

时间:2010-12-15 16:30:34

标签: php xml xpath

任何人都有任何想法如何解决这个问题?单引号给我一个循环。

$nodes = $xml->xpath("//item[contains(@catalog,'Billy's Blogs')]/title");

我试图以各种方式逃避它,都抛出错误:

$nodes = $xml->xpath("//item[contains(@catalog,'Billy\'s Blogs')]/title");
$nodes = $xml->xpath("//item[contains(@catalog,'Billy's Blogs')]/title");

3 个答案:

答案 0 :(得分:3)

使用您的语言中的任何方式(我不知道PHP)来逃避引用字符串中的引号字符,如下所示:

$nodes = $xml->xpath("//item[contains(@catalog,\"Billy's Blogs\")]/title"); 

答案 1 :(得分:3)

salathe回答here时,你无法在XPath中逃避撇号。

答案 2 :(得分:0)

如何使用引用以及'?请参阅here中的示例。notes = 'New Lapytop&quots ;USB" MP3 player&quot'

相关问题