I have a Webservice(API) which I am passing to the DOM parser and it give the parsed result
Code reference :
public void parseContent(){
URL url = new URL(http://My_Webservice_API);
URLConnection con = url.openConnection();
con.setConnectTimeout(5000);
con.setReadTimeout(5000);
Document doc = null;
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
doc = docBuilder.parse(new InputSource(con.getInputStream()));
doc.getDocumentElement().normalize ();
NodeList TC = doc.getElementsByTagName("root");
m_cTotalNo = TC.getLength();
System.out.println("Total no of elements : " + m_cTotalNo);
}
Every thing works fine. The parser breaks on "<element>5>7</element> " . Please put some light how to handle the special character.
XML Entity for "/"?
If the parser really breaks on this (and not on some other character), then that is a bug.
You should encode
>as>in XML.