Re: How to parse this kind of XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I cannot manipulate the response. this is the response I get from the
web services. is there any other way to do it?

On Feb 7, 2008 3:41 PM, Nathan Nobbe <quickshiftin@xxxxxxxxx> wrote:
>
> On Feb 7, 2008 6:17 PM, VamVan <vamseevan@xxxxxxxxx> wrote:
>
>
> > Hi,
> >
> > How can I parse this kind of XML data?
> >
> >  <event:event>
> >
> >
> >  < event:sessionType>9</event:sessionType>
> >
> >  <event:hostWebExID>marketingprograms</event:hostWebExID>
> >
> >  <event:startDate>05/22/2008 09:00:00</event:startDate>
> >
> >  <event:endDate>05/22/2008 10:00:00</event:endDate>
> >
> >  <event:timeZoneID>4</event:timeZoneID>
> >
> >  <event:duration>60</event:duration>
> > </event:event>
> >
> > I am using SimpleXMLElement function but some cannot retrieve the
> > nodes like timeZoneID for example
>
> you will have to define a namespace in the root node of the xml document;
>  then use the SimpleXMLElement::children() method to fetch the nodes in
> that namespace:
>
> $xmlData =
> <<<XMLDATA
>  <event xmlns:event="http://fake.com";>
>
>   <event:sessionType>9</event:sessionType>
>  <event:hostWebExID>marketingprograms</event:hostWebExID>
>  <event:startDate>05/22/2008 09:00:00</event:startDate>
>  <event:endDate>05/22/2008 10:00:00</event:endDate>
>   <event:timeZoneID>4</event:timeZoneID>
>  <event:duration>60</event:duration>
> </event>
> XMLDATA;
>
> $xml = new SimpleXMLElement($xmlData);
> foreach($xml->children('http://fake.com') as $key => $val) {
>      echo "$key => $val" . PHP_EOL;
> }
>
> -nathan
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux