-1

I have a XML file for my project work.I need to fetch the data from the XML file.The file contains something like the following:

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:szgd="http://www.spotzot.com/gdfeed" xmlns:szbb="http://www.spotzot.com/bbfeed">
<channel>
<item>
<title>Service &amp; Maintenance under $50</title>
<description>7 Items | Prestone, Campbell Hausfeld, Custom Accessories, Custom, KD Tools</description>
<szgd:instore>Y</szgd:instore>
</item>
</channel>
</rss>

I am using $newtitle=$newxml->channel->item->title; to fetch data from title.It successfully returned the title.

How can I fetch the data from tag in my page using php?

Subhajyoti De
  • 47
  • 1
  • 2
  • 9

1 Answers1

0

Use php's simplexml functions.

Load it with: $xml = simplexml_load_string($xml); if you are having a string or $xml = simplexml_load_file($xmlFile); if you are having a file.

if the xml was valid you will get a SimpleXmlElement. Check the following link: http://php.net/manual/en/class.simplexmlelement.php. There you will find several functions on how to get data out of it.

Btw. which data you really want to get?

mbo
  • 64
  • 2
  • 10