Getting XML Attribute from Result?

3 messages Options
Embed this post
Permalink
Sebastian Kurt

Getting XML Attribute from Result?

Reply Threaded More More options
Print post
Permalink
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
Dan Dean

Re: Getting XML Attribute from Result?

Reply Threaded More More options
Print post
Permalink
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


alexlavr

Re: Getting XML Attribute from Result?

Reply Threaded More More options
Print post
Permalink
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