Xml parsing problem
Posted: Sat May 31, 2008 5:47 am
Hi,
I am using a web service that response me an xml file like below
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:o='http://a9.com/-/spec/opensearchrss/1.0/'>
<id>http://data.example.com/listings/-/comm ... ta--GA</id>
<link rel="self" type="application/atom+xml" href="http://data.example.com/listings/-/comm ... anta--GA"/>
<updated>2008-05-30T03:46:15+02:00</updated>
<title type='text'>Commercial in Atlanta, Georgia</title>
<o:totalResults>1347</o:totalResults>
<o:startIndex>1</o:startIndex>
<o:itemsPerPage>10</o:itemsPerPage>
<o:Query xmlns:v="http://data.example.com/ns/search" role="request" v:tlocation="Atlanta--GA" v:range="50" startIndex="1" totalResults="10" v:feed="listings" v:category="commercial" />
<v:stem/>
<v:extra/>
<v:site_count>42</v:site_count>
<v:location>
<v:display>Atlanta, GA</v:display>
<v:country>United States</v:country>
<v:state>GA</v:state>
<v:city>Atlanta</v:city>
<v:zip>39901</v:zip>
<v:lat>33.88771</v:lat>
<v:lon>-84.29019</v:lon>
</v:location>
</feed>
I m using the code below its working fine with the elements but those elements that contains columns in tags like below is not catching in the children of simplexml.
<v:zip>39901</v:zip>
<v:lat>33.88771</v:lat>
<v:lon>-84.29019</v:lon>
$xml = simplexml_load_string($result);
foreach($xml->children() as $child)
{
if( $child->getName() == 'entry')
{
echo "<br><b>Name = </b>".$child->getName().":";
echo "<ul>";
foreach($child->children() as $subchild) {
echo "<li>-->".$subchild->getName().":".$subchild."</li>";
}
echo "</ul>";
}
}
anyone have idea what changes will response me those elements
Regards,
Ewalker 99
I am using a web service that response me an xml file like below
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:o='http://a9.com/-/spec/opensearchrss/1.0/'>
<id>http://data.example.com/listings/-/comm ... ta--GA</id>
<link rel="self" type="application/atom+xml" href="http://data.example.com/listings/-/comm ... anta--GA"/>
<updated>2008-05-30T03:46:15+02:00</updated>
<title type='text'>Commercial in Atlanta, Georgia</title>
<o:totalResults>1347</o:totalResults>
<o:startIndex>1</o:startIndex>
<o:itemsPerPage>10</o:itemsPerPage>
<o:Query xmlns:v="http://data.example.com/ns/search" role="request" v:tlocation="Atlanta--GA" v:range="50" startIndex="1" totalResults="10" v:feed="listings" v:category="commercial" />
<v:stem/>
<v:extra/>
<v:site_count>42</v:site_count>
<v:location>
<v:display>Atlanta, GA</v:display>
<v:country>United States</v:country>
<v:state>GA</v:state>
<v:city>Atlanta</v:city>
<v:zip>39901</v:zip>
<v:lat>33.88771</v:lat>
<v:lon>-84.29019</v:lon>
</v:location>
</feed>
I m using the code below its working fine with the elements but those elements that contains columns in tags like below is not catching in the children of simplexml.
<v:zip>39901</v:zip>
<v:lat>33.88771</v:lat>
<v:lon>-84.29019</v:lon>
$xml = simplexml_load_string($result);
foreach($xml->children() as $child)
{
if( $child->getName() == 'entry')
{
echo "<br><b>Name = </b>".$child->getName().":";
echo "<ul>";
foreach($child->children() as $subchild) {
echo "<li>-->".$subchild->getName().":".$subchild."</li>";
}
echo "</ul>";
}
}
anyone have idea what changes will response me those elements
Regards,
Ewalker 99