Exmple Feed:view-source:
@L_404_0@
我只想返回其中父标题节点中包含匹配文本的xml部分,在此示例中,要匹配的文本是“site”.
//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 />"