6
Exmple饲料:查看源代码:http://rss.packetstormsecurity.org/files/tags/exploit/匹配文本与XPath语法
我只是想回到那里父称号节点中有匹配的文本XML的部分,在这个例子中的文本匹配的“地盘” 。
//get feed with curl
$doc = new SimpleXmlElement($xml, LIBXML_NOCDATA);
//$result = $doc->xpath('//title'); //this works returns all the <title>'s
$result = $doc->xpath('//title[site]'); //doesn't work
$result = $doc->xpath('//title[text()="site"]'); //doesn't work
$result = $doc->xpath('//title[contains(site)]'); //doesn't work
$result = $doc->xpath('//title[contains(text(),'Site')]'); //doesn't work
foreach ($result as $title)
echo "$title<br />"
+1正确答案。你写*“我们正在使用当前节点”*。但是`fn:contains()`函数需要两个字符串数据类型参数,所以`self :: node()`缩写语法(`.`)将被转换为`fn:string()`函数,返回它的**字符串值**:所有后代文本节点的连接。 – 2011-01-28 13:40:57