3

I am working on an application where I need to parse some XML files that consists CDATA tags. Parsing ordinary xml is quite straight forward but I am facing problems to retrieve data that is inside the CDATA tag.

The parser:foundCDATA: method is being called for each CDATA tag encountered where the parameter CDATABlock is of NSData type.

Please suggest a way to parse the CDATA tag.

pkamb
  • 33,281
  • 23
  • 160
  • 191
Hariprasad
  • 1,094
  • 2
  • 12
  • 30

2 Answers2

5

If you need to extract the string from CDATA, you could use this block in foundCDATA:

NSMutableString *lStr = [[NSMutableString alloc] initWithData:CDATABlock encoding:NSUTF8StringEncoding];
Oleg Danu
  • 4,149
  • 4
  • 29
  • 47
  • @OlegDanu Please see my question http://stackoverflow.com/questions/43539307/how-to-post-string-with-special-character-using-xml-parsing-in-objective-c. How can I use your code hear – Muju Apr 21 '17 at 10:48
0

i have taken string from the CDATA tag as Oleg Danu said but still it consists XML tags.So i wrote that entire string to a file,whenever CDATA found, and created one more XMLParser by setting the delegate to same class as that of original Parser.All tags in CDATA tag are parsed properly by the secondary parser.The parser will be released at the end of the foundCDATA method and actual parsing continues as it is.

Hariprasad
  • 1,094
  • 2
  • 12
  • 30