tags:

views:

26

answers:

2

I have a xml file file name is file.xml This is content

<PAD_INFO>
    <ITEMS>
        <Item>
            <PAD_URL>http://www.instant-navigator.com/instantn_pad.xml&lt;/PAD_URL&gt;
            <Antivirus_Report_URL>http://instantnavigator-for-onenote.extramind-systems.qarchive.org/antivirusreport.html&lt;/Antivirus_Report_URL&gt;
            <Last_Checking_Date>2010-06-28 05:09:18</Last_Checking_Date>
        </Item>
        <Item>
            <PAD_URL>http://www.mishelpers.com/network_monitor/netmonpro.xml&lt;/PAD_URL&gt;
            <Antivirus_Report_URL>http://alchemy-network-monitor-pro.m-i-s-helpers.qarchive.org/antivirusreport.html&lt;/Antivirus_Report_URL&gt;
            <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&lt;/PAD_URL&gt;
            <Antivirus_Report_URL>http://pdacraft-paint.pdacraft.qarchive.org/antivirusreport.html&lt;/Antivirus_Report_URL&gt;
            <Last_Checking_Date>2010-06-05 01:34:11</Last_Checking_Date>
        </Item>
       </ITEMS>

</PAD_INFO>

Please help me export all file .xml from pad_url tag Use php

Thanks

+3  A: 

You can go for SimpleXML

You might also want to see this nice tutorial:

Introduction To SimpleXML With PHP

Sarfraz
This should be the easiest solution!
faileN
`foreach ($xml->ITEMS->Item as $item) { echo $item->PAD_URL; }` -- hmm, *holy disappearing comments Batman!*
salathe
+1  A: 

As SaC said... SimpleXml is probably the easiest answer here.

// 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();

}
prodigitalson
Or `$xml = new DOMDocument; $xml->load('file.xml'); foreach($xml->getElementsByTagName('PAD_URL') as $pad) { echo $pad->nodeValue; }`
salathe