Exmple Feed:view-source:
http://rss.packetstormsecurity.org/files/tags/exploit/
原文链接:https://www.f2er.com/php/135931.html我只想返回其中父标题节点中包含匹配文本的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 />"