0

This is first time I tried to use SimpleXML... normally I was parsing xml files with regexp, but time to learn something new...

I got XML that contains:

            <resData>
                    <something:infData xmlns:something="<censored>" xsi:schemaLocation="<censored>">
                            <something:name>hello this is my name</something:name>
                            <something:key>
                                    <something:token>fdba8ee15e4473e12ac342ae15acef2</something:token>
                            </something:key>
                    </something:infData>
            </resData>

I am parseing xml via simplexml_load_string() function...

I can get resData as SimpleXMLObject via $xml->resData ... but how do I get something:name and something:key -> something:token ? I cannot use $xml->resData->something:name as it throws an error.

Flash Thunder
  • 11,672
  • 8
  • 47
  • 91
  • possible duplicate of [How to parse SOAP response without SoapClient](http://stackoverflow.com/questions/3928350/how-to-parse-soap-response-without-soapclient) – Peon Nov 25 '13 at 12:54
  • And this might help too: http://stackoverflow.com/a/12969863/1488915 – Peon Nov 25 '13 at 12:55
  • I don't really understand this... so the only way is xpath? – Flash Thunder Nov 25 '13 at 12:59
  • I don't see answer to my question there... as getting list of objects is not what I need... still don't know how to get value from that thread. Could you please simply help me to get from given structure values of those two elements? – Flash Thunder Nov 25 '13 at 13:01

1 Answers1

0

The answer to my question is:

$xml->response->resData->children('something',true)->children('something',true)->name

$xml->response->resData->children('something',true)->children('something',true)->key->children('something',true)->token

Flash Thunder
  • 11,672
  • 8
  • 47
  • 91