Majstor
Majstor

Reputation: 879

Android parse XML which uses < and > instead of "<" and ">"

I'm using a WEB service which return XML format but with &lt; and &gt; instead of "<" and ">".

Now I dont know how to parse it?

I tried the standard SAX parser:

if (entity != null && responseCode==200) {

            // A Simple JSON Response Read
            InputStream instream = entity.getContent();
            BufferedReader rd = null;             
                rd = new BufferedReader(new InputStreamReader(instream));
                InputSource is=new InputSource(rd);
                WebServiceRespondParser parser=new WebServiceRespondParser(category);
                SAXParserFactory factory=SAXParserFactory.newInstance();
                SAXParser sp=factory.newSAXParser();
                XMLReader reader=sp.getXMLReader();
                reader.setContentHandler(parser);
                reader.parse(is);   
                markers=parser.getMarkers();
        }

WEB service:

http://gisn.tel-aviv.gov.il/ws_iriya_zmina/wsgis.asmx/GetData4TargetLayersFromAddress?Format=xml&TargetIriaLayerIDs=659&Radiuses=2000&Rechov=798&Bayit=3&Knisa=

I read few similar question, but most are in different languages, or doesn't have answer.

Upvotes: 1

Views: 1160

Answers (1)

dmon
dmon

Reputation: 30168

That XML is encoded because it's inside the tag. What you need to do is to first parse the original XML, then get the value from the tag. This will get you the proper XML that you can now parse as usual.

Upvotes: 2

Related Questions