<i id='xNuNN'><tr id='xNuNN'><dt id='xNuNN'><q id='xNuNN'><span id='xNuNN'><b id='xNuNN'><form id='xNuNN'><ins id='xNuNN'></ins><ul id='xNuNN'></ul><sub id='xNuNN'></sub></form><legend id='xNuNN'></legend><bdo id='xNuNN'><pre id='xNuNN'><center id='xNuNN'></center></pre></bdo></b><th id='xNuNN'></th></span></q></dt></tr></i><div id='xNuNN'><tfoot id='xNuNN'></tfoot><dl id='xNuNN'><fieldset id='xNuNN'></fieldset></dl></div>

    <small id='xNuNN'></small><noframes id='xNuNN'>

  • <legend id='xNuNN'><style id='xNuNN'><dir id='xNuNN'><q id='xNuNN'></q></dir></style></legend>
    1. <tfoot id='xNuNN'></tfoot>

        • <bdo id='xNuNN'></bdo><ul id='xNuNN'></ul>

        SimpleXML 根据属性值获取元素内容

        SimpleXML get element content based on attribute value(SimpleXML 根据属性值获取元素内容)

        1. <tfoot id='aQr6J'></tfoot>

          1. <legend id='aQr6J'><style id='aQr6J'><dir id='aQr6J'><q id='aQr6J'></q></dir></style></legend>
            <i id='aQr6J'><tr id='aQr6J'><dt id='aQr6J'><q id='aQr6J'><span id='aQr6J'><b id='aQr6J'><form id='aQr6J'><ins id='aQr6J'></ins><ul id='aQr6J'></ul><sub id='aQr6J'></sub></form><legend id='aQr6J'></legend><bdo id='aQr6J'><pre id='aQr6J'><center id='aQr6J'></center></pre></bdo></b><th id='aQr6J'></th></span></q></dt></tr></i><div id='aQr6J'><tfoot id='aQr6J'></tfoot><dl id='aQr6J'><fieldset id='aQr6J'></fieldset></dl></div>
              <tbody id='aQr6J'></tbody>
              • <small id='aQr6J'></small><noframes id='aQr6J'>

                  <bdo id='aQr6J'></bdo><ul id='aQr6J'></ul>
                • 本文介绍了SimpleXML 根据属性值获取元素内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试根据属性的值访问元素的内容.使用 PHP SimpleXML.我有以下 XML 设置:

                  I'm trying to access the content of an element based on the value of an attribute. With PHP SimpleXML. I've got the following XML setup:

                  <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>
                  

                  这些是书.在这种情况下,我试图获得标题.我到目前为止是这样的:

                  These are books. In this case I'm trying to get the title. What I have so far is this:

                  $xml = simplexml_load_file(url);
                  $docs = $xml->DocSum;
                  foreach($docs as $book){
                          // Each book individual
                  }
                  

                  评论在哪里我尝试了很多东西.

                  Where the comment is I tried a lot of things.

                  推荐答案

                  这个 XPath 查询在 SimpleXML 对象上将返回所有 DocSum 节点,这些节点具有 Item 子节点,Name 属性中的值为Author",值为Olivera GC"在文本节点中:

                  This XPath query on the SimpleXML object will return all DocSum nodes that have an Item child with value "Author" in the Name attribute and value "Olivera GC" in the text node:

                  $nodes = $xml->xpath('//DocSum[Item[@Name="Author" and .="Oliveira GC"]]');
                  $book = $nodes[0];
                  print_r($book);
                  

                  这篇关于SimpleXML 根据属性值获取元素内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='xM1fX'></small><noframes id='xM1fX'>

                    <bdo id='xM1fX'></bdo><ul id='xM1fX'></ul>

                        <tbody id='xM1fX'></tbody>

                      1. <legend id='xM1fX'><style id='xM1fX'><dir id='xM1fX'><q id='xM1fX'></q></dir></style></legend>
                            <i id='xM1fX'><tr id='xM1fX'><dt id='xM1fX'><q id='xM1fX'><span id='xM1fX'><b id='xM1fX'><form id='xM1fX'><ins id='xM1fX'></ins><ul id='xM1fX'></ul><sub id='xM1fX'></sub></form><legend id='xM1fX'></legend><bdo id='xM1fX'><pre id='xM1fX'><center id='xM1fX'></center></pre></bdo></b><th id='xM1fX'></th></span></q></dt></tr></i><div id='xM1fX'><tfoot id='xM1fX'></tfoot><dl id='xM1fX'><fieldset id='xM1fX'></fieldset></dl></div>
                            <tfoot id='xM1fX'></tfoot>