I
I
Ilya2018-09-22 00:15:07
PHP
Ilya, 2018-09-22 00:15:07

xml response comes, how to parse (read) it?

I receive an xml file:

<horo>
<date yesterday="21.09.2018" today="22.09.2018" tomorrow="23.09.2018" tomorrow02="24.09.2018"/>

and I need to get today's date: 09/22/2018 Tell me how to do this.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-09-22
Dobryak @rusVolk

$answer=<<<XML
<horo>
    <date yesterday="21.09.2018" today="22.09.2018" tomorrow="23.09.2018" tomorrow02="24.09.2018"/>
</horo>
XML;

$xml=simplexml_load_string($answer);
print_r($xml->date[today]);

S
Sergey, 2018-09-22
@gangstarcj

simplexml get attribute value choose any

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question