Getting XML Attribute from Result?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting XML Attribute from Result?

Sebastian Kurt
Hi,
I use Zend/Rest/Client to call an API. I get a XML-File as result. No
problem to get values from a node, but how can I get an attribute?

Example:
<who id="foo">
<tags>
<tag count="10">bar</tag>
<tag count="10">bar1</tag>
</tags>
</who>

$tagstring = $result->who(); results in (bar,bar1)

But how do I get "count" to work with it?

THANKS
Sebastian
--
mailto:[hidden email]
http://skurt.de
0179 7923088
Reply | Threaded
Open this post in threaded view
|

Re: Getting XML Attribute from Result?

Dan Dean
Hello,

Sebastian Kurt wrote
Hi,
I use Zend/Rest/Client to call an API. I get a XML-File as result. No
problem to get values from a node, but how can I get an attribute?
I believe you can treat the response xml as you would a simplexml object, and access node attributes as you do an array. See both the framework documentation, and simplexml documentation example 2226:

http://framework.zend.com/manual/en/zend.rest.client.html#zend.rest.client.return
http://us.php.net/simplexml


Reply | Threaded
Open this post in threaded view
|

Re: Getting XML Attribute from Result?

alexlavr
In reply to this post by Sebastian Kurt
Hi,

I am having the same problem with Zend Rest Result not providing a way to access an element's attribute. Did you find a solution?

Alex


Sebastian Kurt wrote
Hi,
I use Zend/Rest/Client to call an API. I get a XML-File as result. No
problem to get values from a node, but how can I get an attribute?

Example:
<who id="foo">
<tags>
<tag count="10">bar</tag>
<tag count="10">bar1</tag>
</tags>
</who>

$tagstring = $result->who(); results in (bar,bar1)

But how do I get "count" to work with it?

THANKS
Sebastian
--
mailto:skurt@gmx.de
http://skurt.de
0179 7923088