Getting XML Attribute from Result?

View: New views
2 Messages — Rating Filter:   Alert me  

Getting XML Attribute from Result?

by Sebastian Kurt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
http://skurt.de
0179 7923088

Re: Getting XML Attribute from Result?

by Dan Dean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


LightInTheBox - Buy quality products at wholesale price!