1 回答
TA贡献1876条经验 获得超6个赞
你要找的方法query不是xpath
然后您可以更新路径以匹配 Name 包含的 WebFilterCategoryCategoryname2
//WebFilterCategory[Name[contains(., "Categoryname2")]]'
更新代码
$xml = simplexml_load_string( $xmlstring ) or die("Error: Cannot create object");
foreach ($xml->xpath('//WebFilterCategory[Name[contains(., "Categoryname2")]]') as $category) {
print_r($category);
}
输出
SimpleXMLElement Object
(
[@attributes] => Array
(
[transactionid] =>
)
[Name] => Categoryname2
[Classification] => Objectionable
[DomainList] => SimpleXMLElement Object
(
[Domain] => Array
(
[0] => example3.org
[1] => example2.org
)
)
)
- 1 回答
- 0 关注
- 109 浏览
添加回答
举报