A
A
Alex F2015-07-07 20:14:14
PHP
Alex F, 2015-07-07 20:14:14

How to get value from xml to php?

Available:
1.

<forecast xmlns="http://weather.yandex.ru/forecast" city="Ленинск-Кузнецкий" country="Россия" region="11285" lon="86.179122" zoom="12" id="29744" source="Forecast" country_id="1ed1c408a4ac822b728a2077a1d9935c" link="http://pogoda.yandex.ru/leninsk-kuznetskiy/" part_id="5f1a76eb94a6e7651cd0d4296d843d40" geoid="11285" lat="54.668171" exactname="Ленинск-Кузнецкий" part="Кемеровская область" slug="leninsk-kuznetskiy">

2.
<temperature color="F7F3D3" plate="fff28e">17</temperature>

Please tell me how to "get" city from the first one, and color from the second one ?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pesenka1, 2015-07-07
@pesenka1

RTFM

X
xmoonlight, 2015-07-07
@xmoonlight

regexp

I
impass, 2015-07-08
@impass

Something more convenient than XPath for sampling from XML or HTML is hard to come up with. So it's better to use DOMDocument + DOMXPath .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question