A
A
Alexey Voropaev2017-05-24 14:28:08
PHP
Alexey Voropaev, 2017-05-24 14:28:08

How to get value from xml?

I have xml:

<response uri="/crm"><result><message>Record(s) updated successfully</message><recorddetail><FL val="Id">171657000023650001</FL><FL val="Created Time">2017-05-23 12:07:10</FL><FL val="Modified Time">2017-05-24 03:41:40</FL><FL val="Created By"><![CDATA[User]]></FL><FL val="Modified By"><![CDATA[User]]></FL></recorddetail></result></response>

I form an object:
$result = simplexml_load_string( $xml );
I need to get the value from , that is, I should get - 171657000023650001. How to do this? Tried like this:<FL val="Id">171657000023650001</FL>
print_r( $result->result->recorddetail->FL[0] );
print_r( $result->result->recorddetail->xpath( 'FL="@val"' ) );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-05-24
@boomrap

$id = "{$xml->result->recorddetail->xpath('FL[@val="Id"]')[0]}";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question