是否可以让XPath表达式包含多个包含不同元素值的表达式?
<data> <person> <firstname>Kerry</firstname> <lastname>Packer</lastname> <address>Crown</address> <person> <person> <firstname>Kerry</firstname> <lastname>Murdoch</lastname> <address>California</address> <person> <data>
$xml = simplexml_load_string($data); $elements = $xml->xpath("(//person)[firstname[contains(.,'Kerr')]] and [lastname[contains(.,'och')]]");
目前,上面的XPath表达式被标记为无效.但是,如果我将它与一个元素一起使用,
$xml->xpath("(//person)[firstname[contains(.,'Kerr')]]");
然后它工作正常.
你只是想要
原文链接:https://www.f2er.com/php/135689.html//person[contains(firstname,'Kerr') and contains(lastname,'och')]