Uday
Uday

Reputation: 6023

Parsing issues while parsing xml response android

Xml response is like , but in one tag , the text is this:

<Description>
    &lt;center&gt;&lt;strong&gt;&lt;span&gt;Warehouse / Building Maintenance&lt;/span&gt;&lt;/strong&gt;&lt;/center&gt;&lt;br /&gt;
    &lt;br /&gt;
    &lt;strong&gt;&lt;span&gt;I&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;mmediate openings available in the local Perris area for warehouse/building building maintenance positions. &lt;br /&gt;
    &lt;br /&gt;
    &lt;strong&gt;Job Description:&lt;/strong&gt;&lt;br /&gt;
    &lt;/span&gt;
    &lt;ul&gt;
        &lt;li&gt;&lt;span&gt;Associates will be responsible to define pieces of equipment that will paralyze operations if they fail, and plan whatever level of preventative maintenance necessary. &lt;br /&gt;
        &lt;/span&gt;&lt;/li&gt;
        &lt;li&gt;&lt;span&gt
......
similar text
......
</Description>

I can't able to parse it in proper way.

I tried using Jsoup.parse((nodeValue))

and Html.fromHtml(String) also URLEncoder.encode(String)

but its returning simple & symbol thats it.

How to parse this type of response?

Upvotes: 0

Views: 356

Answers (2)

Uday
Uday

Reputation: 6023

Actually its returning only & symbol , that's because the nodelist item returns only single value.

After using like this:

NodeList fstNm = fstNmElmnt.getChildNodes();

                    System.out.println("nodefstnm"+fstNm.getLength());

                    for(int j=0;j<fstNm.getLength();j++) {
                       String val = ((Node) fstNm.item(j)).getNodeValue();
                       nodeValue=nodeValue.concat(val);
                    }

and then parsing with Jsoup., returns what I want.

Upvotes: 0

Sephy
Sephy

Reputation: 50442

A temporary solution could be applying replaceAll("&lt;", "<").replaceAll("&gt;", ">") if API methods aren't working, but arent you supposed to use Html.toHtml(string) when you have stuff encoded and want it to become real html ?

Upvotes: 1

Related Questions