1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Next Door
    Rep Power

    Access an elements attribute in <![CDATA[ (SimpleXml)

    How is it possible to access the value for attribute src (src="http://l.yimg.com/a/i/us/we/52/29.gif") in this page.

    Red below:

    <?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#">

    <title>Yahoo! Weather - City of Gold Coast, AU</title>
    <description>Yahoo! Weather for City of Gold Coast, AU</description>
    <lastBuildDate>Sat, 30 Mar 2013 8:29 pm ACST</lastBuildDate>
    <yweather:location city="City of Gold Coast" region="QLD" country="Australia"/>
    <yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
    <yweather:wind chill="72" direction="300" speed="5" />
    <yweather:atmosphere humidity="73" visibility="6.21" pressure="29.97" rising="1" />
    <yweather:astronomy sunrise="6:52 am" sunset="6:45 pm"/>
    <title>Yahoo! Weather</title>
    <title>Conditions for City of Gold Coast, AU at 8:29 pm ACST</title>
    <pubDate>Sat, 30 Mar 2013 8:29 pm ACST</pubDate>
    <yweather:condition text="Cloudy" code="26" temp="72" date="Sat, 30 Mar 2013 8:29 pm ACST" />
    <img src="http://l.yimg.com/a/i/us/we/52/26.gif"/><br />
    <b>Current Conditions:</b><br />
    Cloudy, 72 F<BR />
    <BR /><b>Forecast:</b><BR />
    Sat - Mostly Clear. High: 77 Low: 70<br />
    Sun - Isolated Thunderstorms. High: 78 Low: 71<br />
    <br />
    <a href="http://us.rd.yahoo.com/dailynews/rss/weather/City_of_Gold_Coast__AU/*http://weather.yahoo.com/forecast/ASXX0047_f.html">Full Forecast at Yahoo! Weather</a><BR/><BR/>
    (provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>
    <yweather:forecast day="Sat" date="30 Mar 2013" low="70" high="77" text="Mostly Clear" code="33" />
    <yweather:forecast day="Sun" date="31 Mar 2013" low="71" high="78" text="Isolated Thunderstorms" code="37" />
    <guid isPermaLink="false">ASXX0047_2013_03_31_7_00_ACST</guid>

    <!-- api11.weather.sp2.yahoo.com Sat Mar 30 10:27:19 PST 2013 -->
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Rep Power
    Use DOM and 'find'.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Next Door
    Rep Power
    Originally Posted by gw1500se
    Use DOM and 'find'.
    Not possible with simplexml?
  6. #4
  7. Reversible Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Washington, USA
    Rep Power
    SimpleXML will get you the contents of the CDATA. Put those into a DOMDocument, getElementsByTagName, and grab the attribute from there.

    Comments on this post

    • gw1500se agrees : I should have been more explicit like you.

IMN logo majestic logo threadwatch logo seochat tools logo