За последние 24 часа нас посетили 19136 программистов и 1642 робота. Сейчас ищут 874 программиста ...

simplexml

Тема в разделе "Прочие вопросы по PHP", создана пользователем DAmlex, 17 июн 2009.

  1. DAmlex

    DAmlex Активный пользователь

    С нами с:
    17 июн 2009
    Сообщения:
    3
    Симпатии:
    0
    Подскажите плз как вытащить данные из этого xml:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
    <channel>

    <title>Yahoo! Weather - Moscow, RS</title>
    <link>http://us.rd.yahoo.com/dailynews/rss/weather/Moscow__RS/*http://weather.yahoo.com/forecast/RSXX0063_f.html</link>
    <description>Yahoo! Weather for Moscow, RS</description>
    <language>en-us</language>
    <lastBuildDate>Wed, 17 Jun 2009 1:00 pm MSD</lastBuildDate>
    <ttl>60</ttl>
    <yweather:location city="Moscow" region="" country="RS"/>

    <yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
    <yweather:wind chill="62" direction="160" speed="4" />
    <yweather:atmosphere humidity="93" visibility="2.49" pressure="29.15" rising="0" />
    <yweather:astronomy sunrise="4:45 am" sunset="10:15 pm"/>
    <image>
    <title>Yahoo! Weather</title>
    <width>142</width>
    <height>18</height>
    <link>http://weather.yahoo.com</link>
    <url>http://l.yimg.com/a/i/us/nws/th/main_142b.gif</url>
    </image>
    <item>

    <title>Conditions for Moscow, RS at 1:00 pm MSD</title>
    <geo:lat>55.97</geo:lat>
    <geo:long>37.42</geo:long>
    <link>http://us.rd.yahoo.com/dailynews/rss/weather/Moscow__RS/*http://weather.yahoo.com/forecast/RSXX0063_f.html</link>
    <pubDate>Wed, 17 Jun 2009 1:00 pm MSD</pubDate>
    <yweather:condition text="Rain Shower" code="11" temp="62" date="Wed, 17 Jun 2009 1:00 pm MSD" />
    <description><![CDATA[
    <img src="http://l.yimg.com/a/i/us/we/52/11.gif"/><br />
    <b>Current Conditions:</b><br />
    Rain Shower, 62 F<BR />
    <BR /><b>Forecast:</b><BR />
    Wed - Clouds Early/Clearing Late. High: 65 Low: 49<br />
    Thu - Partly Cloudy. High: 67 Low: 48<br />
    <br />
    <a href="http://us.rd.yahoo.com/dailynews/rss/weather/Moscow__RS/*http://weather.yahoo.com/forecast/RSXX0063_f.html">Full Forecast at Yahoo! Weather</a><BR/>
    (provided by The Weather Channel)<br/>
    ]]></description>
    <yweather:forecast day="Wed" date="17 Jun 2009" low="49" high="65" text="Clouds Early/Clearing Late" code="29" />
    <yweather:forecast day="Thu" date="18 Jun 2009" low="48" high="67" text="Partly Cloudy" code="30" />
    <guid isPermaLink="false">RSXX0063_2009_06_17_13_00_MSD</guid>
    </item>

    </channel>
    </rss>


    А именно
    <img src="http://l.yimg.com/a/i/us/we/52/11.gif"/><br />
    <yweather:condition text="Rain Shower" code="11" temp="62" date="Wed, 17 Jun 2009 1:00 pm MSD" />
     
  2. alexey_baranov

    alexey_baranov Активный пользователь

    С нами с:
    3 фев 2009
    Сообщения:
    647
    Симпатии:
    0
    Адрес:
    Сургут
    А что просто как есть $rss->channel->image->link и $rss->channel->childrens()->выбрать из них то, который с condition ->asXML() не работает?

    проблема-то в чем?
     
  3. DAmlex

    DAmlex Активный пользователь

    С нами с:
    17 июн 2009
    Сообщения:
    3
    Симпатии:
    0
    $rss->channel->image->link выводит http://weather.yahoo.com а должен <img src="http://l.yimg.com/a/i/us/we/52/11.gif"/>т.е картинку
    $rss->channel->childrens()->выбрать из них то, который с condition ->asXML() не работает? -"Это вообще не понял
     
  4. alexey_baranov

    alexey_baranov Активный пользователь

    С нами с:
    3 фев 2009
    Сообщения:
    647
    Симпатии:
    0
    Адрес:
    Сургут
    link на url замени.

    про второе на меня не надейся. читай мануал SimpleXMLElement, что тебе весь ман здесь переписывать?
     
  5. DAmlex

    DAmlex Активный пользователь

    С нами с:
    17 июн 2009
    Сообщения:
    3
    Симпатии:
    0
    Выводит опять не ту ссылку а именно из этого блока <url>http://l.yimg.com/a/i/us/nws/th/main_142b.gif</url>