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

    2. <legend id='zDe4p'><style id='zDe4p'><dir id='zDe4p'><q id='zDe4p'></q></dir></style></legend>
      • <bdo id='zDe4p'></bdo><ul id='zDe4p'></ul>

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

      1. 如何使用 php 解析 XML 文件

        How to parse XML file using php(如何使用 php 解析 XML 文件)
        <legend id='zQ413'><style id='zQ413'><dir id='zQ413'><q id='zQ413'></q></dir></style></legend>

      2. <small id='zQ413'></small><noframes id='zQ413'>

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

            <tfoot id='zQ413'></tfoot>

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

                  本文介绍了如何使用 php 解析 XML 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想解析下面的xml并获取metadata:description using php的值

                  I want to parse the following xml and get the value of metadata:description using php

                  我知道如何获取title的值

                  I know how to get the value of title

                  $item_title = $x -> item($i) -> getElementsByTagName('title') -> item(0) -> childNodes -> item(0) -> nodeValue;
                  

                  但不能用这种方式获取元数据:描述

                  but can not use this way to get metadata:description

                  <item>
                    <title>Jobs: Bullish Economy Confirmed?</title>
                    <metadata:title xmlns:metadata="http://search.cnbc.com/rss/2.0/modules/siteContentMetadata">Jobs: Bullish Economy Confirmed?  06 Jan 2012</metadata:title>
                    <description>Discussing whether the better than expected jobs number point to an economic rebound, and where to invest in this market, with Michael Farr, Farr, Miller, &amp; Washington president.</description>
                    <metadata:description xmlns:metadata="http://search.cnbc.com/rss/2.0/modules/siteContentMetadata"><![CDATA[<div class="rss_image" style="float:left;padding-right:10px;"><img border="0" vspace="0" hspace="0" width="93" src="http://thumbnails.cnbc.com/VCPS/Y2012/M01D06/3000066213/6ED1-KR-Jobs_sm.jpg"></div><div class="rss_abstract" style="font:Arial 12px;width:100%;float:left;clear:both">Discussing whether the better than expected jobs number point to an economic rebound, and where to invest in this market, with Michael Farr, Farr, Miller, &amp; Washington president.</div>]]></metadata:description>
                    <pubDate>Sat, 07 Jan 2012 00:24 GMT</pubDate>
                    <guid isPermaLink="false">http://www.cnbc.com//id/15840232?video=3000066213&amp;play=1</guid>
                    <link>http://www.cnbc.com//id/15840232?video=3000066213&amp;play=1</link>
                  </item>
                  

                  <小时>

                  原始xml文件链接


                  Original xml file link

                  http://www.cnbc.com/id/19838222/device/rss/rss.xml
                  

                  推荐答案

                  使用 SimpleXML

                  $xmlstr='<item>
                  <title>Jobs: Bullish Economy Confirmed?</title>
                  <metadata:title xmlns:metadata="http://search.cnbc.com/rss/2.0/modules/siteContentMetadata">Jobs: Bullish Economy Confirmed?  06 Jan 2012</metadata:title>
                  <description>Discussing whether the better than expected jobs number point to an economic rebound, and where to invest in this market, with Michael Farr, Farr, Miller, &amp; Washington president.</description>
                  <metadata:description xmlns:metadata="http://search.cnbc.com/rss/2.0/modules/siteContentMetadata"><![CDATA[<div class="rss_image" style="float:left;padding-right:10px;"><img border="0" vspace="0" hspace="0" width="93" src="http://thumbnails.cnbc.com/VCPS/Y2012/M01D06/3000066213/6ED1-KR-Jobs_sm.jpg"></div><div class="rss_abstract" style="font:Arial 12px;width:100%;float:left;clear:both">Discussing whether the better than expected jobs number point to an economic rebound, and where to invest in this market, with Michael Farr, Farr, Miller, &amp; Washington president.</div>]]></metadata:description>
                  <pubDate>Sat, 07 Jan 2012 00:24 GMT</pubDate>
                  <guid isPermaLink="false">http://www.cnbc.com//id/15840232?video=3000066213&amp;play=1</guid>
                  <link>http://www.cnbc.com//id/15840232?video=3000066213&amp;play=1</link>
                  </item>';
                  
                  $x= new SimpleXMLElement($xmlstr);
                  echo $x->title;
                  $nss = $x->getNameSpaces(true);
                  $metadata = $x->children($nss['metadata']); 
                  echo $metadata->title, "
                  ";
                  echo $metadata->description, "
                  ";
                  

                  输出

                  Jobs: Bullish Economy Confirmed?Jobs: Bullish Economy Confirmed?  06 Jan 2012
                  <div class="rss_image" style="float:left;padding-right:10px;"><img border="0" vspace="0" hspace="0" width="93" src="http://thumbnails.cnbc.com/VCPS/Y2012/M01D06/3000066213/6ED1-KR-Jobs_sm.jpg"></div><div class="rss_abstract" style="font:Arial 12px;width:100%;float:left;clear:both">Discussing whether the better than expected jobs number point to an economic rebound, and where to invest in this market, with Michael Farr, Farr, Miller, &amp; Washington president.</div>
                  

                  这篇关于如何使用 php 解析 XML 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

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

                    <tfoot id='ZRSPV'></tfoot>
                        <tbody id='ZRSPV'></tbody>
                      • <bdo id='ZRSPV'></bdo><ul id='ZRSPV'></ul>

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