0

i am getting problem while reading xml files through nsxmlparser in ios,

<PRODUCTS>
    <PRODUCTSLIST>
        <PRODUCTDETAILS>
                <headertext> test header </headertext>
                <description><b style="font-size: x-small;">product, advantages</b></description>
        </PRODUCTDETAILS>
    </PRODUCTSLIST>
</PRODUCTS>

while i read the file using nsxmlparser i am able to get value(test header) for headertext but the description attribute value contains html tags so i cant able to get the result (<b style="font-size: x-small;">product, advantages</b>)i am getting result as empty How can i get the result as((<b style="font-size: x-small;">product, advantages</b>)) for description attribute?

2 Answers2

2

Speaking from a developers perspective I would not recommend using NSXMLParser due to it's laborious way to parse XML Files. There is a great write up about choosing the right XML Parser.

I use KissXML quite often. You can find a quit tutorial of using it here.

Hope this helps.

Community
  • 1
  • 1
btype
  • 1,593
  • 19
  • 32
  • that's ok for 'smaller' files. but a DOM parser will eat up a lot of memory *btw, kissXML tries to emulate NSXML for mac so you can also read that docs* – Daij-Djan Apr 05 '13 at 07:48
  • I used it for files larger than 4000 lines and it worked well. But I only used it to parse the Data and stored it into CoreData. – btype Apr 05 '13 at 07:58
  • Reading xml file , i have only maximum 50 records if i use KissXml means it have so many class files and memory... – Karthik Apr 05 '13 at 08:03
  • 4000 lines is small.... thats why I said 'small' -- Im using KissXML in a web scraper and it is **great** but when you have to deal with XMLs that are in the 10 MB+ range..... it might not be a good fit -- oh and it is slow in comparison! – Daij-Djan Apr 05 '13 at 08:31
0

Your problem is that the "b" tag is considered part of the XML structure, try escaping the '<' and '>' characters of the 'b' tag:
@"&lt;b style=\"font-size: x-small;&gt;product, advantages&lt;/b&gt;"
see here

Community
  • 1
  • 1
Dan Shelly
  • 5,991
  • 2
  • 22
  • 26
  • that description attribute comming from service so that column having dynamic values .... if bold we can try like this suppose font and other tag came means how can i manage that .. – Karthik Apr 05 '13 at 08:05