参见英文答案 >
Implementing condition in XPath 2
我正在尝试根据属性的值访问元素的内容.使用PHP SimpleXML.我有以下XML设置:
原文链接:https://www.f2er.com/php/139879.html我正在尝试根据属性的值访问元素的内容.使用PHP SimpleXML.我有以下XML设置:
<DocSum> <Id>21242919</Id> <Item Name="Author" Type="String">Nguyen T</Item> <Item Name="Title" Type="String">[Hemoptysis and spontaneous rupture of a primary renal angiosarcoma: a case report.]</Item> </DocSum> <DocSum> <Id>21242919</Id> <Item Name="Author" Type="String">Oliveira GC</Item> <Item Name="Title" Type="String">Disclosing ambiguous gene aliases by automatic literature profiling.</Item> </DocSum> <DocSum> <Id>21242919</Id> <Item Name="Author" Type="String">Vanderwall DE</Item> <Item Name="Title" Type="String">Metformin and digestive disorders.</Item> </DocSum>
这些都是书.在这种情况下,我试图获得标题.我到目前为止是这样的:
$xml = simplexml_load_file(url); $docs = $xml->DocSum; foreach($docs as $book){ // Each book individual }
哪里的评论是我尝试了很多东西.