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

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

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

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

        php domdocument获取属性值所在的节点值

        php domdocument get node value where attribute value is(php domdocument获取属性值所在的节点值)
        1. <legend id='zLXcS'><style id='zLXcS'><dir id='zLXcS'><q id='zLXcS'></q></dir></style></legend>
          • <bdo id='zLXcS'></bdo><ul id='zLXcS'></ul>
            <i id='zLXcS'><tr id='zLXcS'><dt id='zLXcS'><q id='zLXcS'><span id='zLXcS'><b id='zLXcS'><form id='zLXcS'><ins id='zLXcS'></ins><ul id='zLXcS'></ul><sub id='zLXcS'></sub></form><legend id='zLXcS'></legend><bdo id='zLXcS'><pre id='zLXcS'><center id='zLXcS'></center></pre></bdo></b><th id='zLXcS'></th></span></q></dt></tr></i><div id='zLXcS'><tfoot id='zLXcS'></tfoot><dl id='zLXcS'><fieldset id='zLXcS'></fieldset></dl></div>
                <tbody id='zLXcS'></tbody>

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

              • <tfoot id='zLXcS'></tfoot>

                  本文介绍了php domdocument获取属性值所在的节点值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我的 XML 如下所示:

                  Say my XML looks like this:

                  <record>
                    <row name="title">this item</row>
                    <row name="url">this url</row>
                  </record>
                  

                  现在我正在做这样的事情:

                  Now I'm doing something like this:

                  $xml = new DOMDocument();
                  $xml->load('xmlfile.xml');
                  
                  echo $xml->getElementByTagName('row')->item(0)->attributes->getNamedItem('title')->nodeValue;
                  

                  但这只是给了我:

                  注意:试图获取非对象 id 的属性

                  NOTICE: Trying to get property of non-object id

                  有人知道如何获取name"属性值为title"的节点值吗?

                  Does anybody know how to get the node value where the "name" attribute has value "title"?

                  推荐答案

                  试试:

                  $xml = new DOMDocument();
                  $xml->loadXml('
                  <record>
                    <row name="title">this item</row>
                    <row name="url">this url</row>
                  </record>
                  ');
                  
                  $xpath = new DomXpath($xml);
                  
                  // traverse all results
                  foreach ($xpath->query('//row[@name="title"]') as $rowNode) {
                      echo $rowNode->nodeValue; // will be 'this item'
                  }
                  
                  // Or access the first result directly
                  $rowNode = $xpath->query('//row[@name="title"][1]')->item(0);
                  if ($rowNode instanceof DomElement) {
                      echo $rowNode->nodeValue;
                  }
                  

                  这篇关于php domdocument获取属性值所在的节点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='32xpF'></small><noframes id='32xpF'>

                  • <tfoot id='32xpF'></tfoot>

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

                            <tbody id='32xpF'></tbody>