user1542476
user1542476

Reputation:

retrieve xml file using nsxmlparser in ios

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?

Upvotes: 0

Views: 236

Answers (2)

Dan Shelly
Dan Shelly

Reputation: 6011

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

Upvotes: 0

btype
btype

Reputation: 1576

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.

Upvotes: 2

Related Questions