2

Im working through an example iphone tutorial on parsing the google weather api, The api seems to no longer exist so I have sourced an alternative. The tutorial uses libxml2 and xpath query to parse the xml file. I am succesfully parsing most of the data. The problem I have is that the icons url for the weather symbols are enclosed in CDATA sections:

 <weatherIconUrl><![CDATA[http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0010_heavy_rain_showers.png]]></weatherIconUrl>

I understand that xpath cannot read items enclosed in CDATA . Is anyway of pulling this data from within the tags?

Coasty
  • 49
  • 1
  • 5
  • 1
    Same as http://stackoverflow.com/questions/4816422/how-to-handle-the-cdata-tag-while-parsing-the-xml-file-in-ipad/4818676#4818676 – Oleg Danu Jan 31 '11 at 14:29

1 Answers1

5

Use parser:foundCDATA:

- (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock

to parse CDATA.

https://developer.apple.com/documentation/foundation/nsxmlparserdelegate/1407687-parser

pkamb
  • 33,281
  • 23
  • 160
  • 191
Oleg Danu
  • 4,149
  • 4
  • 29
  • 47