Php 如何从xml导出

Php 如何从xml导出,php,xml,Php,Xml,我有一个xml文件,文件名是file.xml 这就是内容 <PAD_INFO> <ITEMS> <Item> <PAD_URL>http://www.instant-navigator.com/instantn_pad.xml</PAD_URL> <Antivirus_Report_URL>http://instantnavigator-for-onen

我有一个xml文件,文件名是file.xml 这就是内容

<PAD_INFO>
    <ITEMS>
        <Item>
            <PAD_URL>http://www.instant-navigator.com/instantn_pad.xml</PAD_URL>
            <Antivirus_Report_URL>http://instantnavigator-for-onenote.extramind-systems.qarchive.org/antivirusreport.html</Antivirus_Report_URL>
            <Last_Checking_Date>2010-06-28 05:09:18</Last_Checking_Date>
        </Item>
        <Item>
            <PAD_URL>http://www.mishelpers.com/network_monitor/netmonpro.xml</PAD_URL>
            <Antivirus_Report_URL>http://alchemy-network-monitor-pro.m-i-s-helpers.qarchive.org/antivirusreport.html</Antivirus_Report_URL>
            <Last_Checking_Date>2010-06-03 08:00:43</Last_Checking_Date>
        </Item>
        <Item>
            <PAD_URL>http://www.pdacraft.com/pad/pdacraft_paint_pad.xml</PAD_URL>
            <Antivirus_Report_URL>http://pdacraft-paint.pdacraft.qarchive.org/antivirusreport.html</Antivirus_Report_URL>
            <Last_Checking_Date>2010-06-05 01:34:11</Last_Checking_Date>
        </Item>
       </ITEMS>

</PAD_INFO>

http://www.instant-navigator.com/instantn_pad.xml
http://instantnavigator-for-onenote.extramind-systems.qarchive.org/antivirusreport.html
2010-06-28 05:09:18
http://www.mishelpers.com/network_monitor/netmonpro.xml
http://alchemy-network-monitor-pro.m-i-s-helpers.qarchive.org/antivirusreport.html
2010-06-03 08:00:43
http://www.pdacraft.com/pad/pdacraft_paint_pad.xml
http://pdacraft-paint.pdacraft.qarchive.org/antivirusreport.html
2010-06-05 01:34:11
请帮助我从pad_url标记导出所有file.xml 使用php

谢谢

你可以去

您可能还想看看这本不错的教程:

你可以去

您可能还想看看这本不错的教程:


正如SaC所说。。。SimpleXml可能是这里最简单的答案

// assume $xmlstring is the xml you posted

$xml = new SimpleXmlElement($xmlstring);
$urls = $xml->xpath('//PAD_URL');

foreach($urls as $url)
{
  // when used in a string contect $url will be the text value
  echo $url;

  // however its still really the object so for example if you needed te attributes
  $attributes = $url->attributes();

}

正如SaC所说。。。SimpleXml可能是这里最简单的答案

// assume $xmlstring is the xml you posted

$xml = new SimpleXmlElement($xmlstring);
$urls = $xml->xpath('//PAD_URL');

foreach($urls as $url)
{
  // when used in a string contect $url will be the text value
  echo $url;

  // however its still really the object so for example if you needed te attributes
  $attributes = $url->attributes();

}

这应该是最简单的解决方案
foreach($xml->ITEMS->ITEMS as$Item){echo$Item->PAD_URL;}
--hmm,蝙蝠侠!这应该是最简单的解决方案
foreach($xml->ITEMS->ITEMS as$Item){echo$Item->PAD_URL;}
--hmm,蝙蝠侠!或
$xml=新文档$xml->load('file.xml');foreach($xml->getElementsByTagName('PAD_URL')作为$PAD){echo$PAD->nodeValue;}
$xml=newdomdocument$xml->load('file.xml');foreach($xml->getElementsByTagName('PAD_URL')作为$PAD){echo$PAD->nodeValue;}