简体   繁体   中英

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?

如果API方法不起作用,则临时解决方案可能是应用replaceAll(“ &lt; ”,“ <”)。replaceAll(“ &gt; ”,“>”),但是当您应在以下情况下使用Html.toHtml(string)您已经编码了东西,并希望它成为真正的html吗?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM