List of utility methods to do XML Parse
Document | parse(File source) parse DocumentBuilder builder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
return builder.parse(source);
|
Document | parse(String source) parse DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); return builder.parse(new ByteArrayInputStream(source.getBytes())); |
T | parse(String xml) parse SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parse = factory.newSAXParser();
return null;
|
List | parse(String xmlstr, Class> clazz, List parse List<Object> list = new ArrayList<Object>(); try { XmlPullParser xmlPullParser = Xml.newPullParser(); xmlPullParser.setInput(new StringReader(xmlstr)); int event = xmlPullParser.getEventType(); Object obj = null; while (event != XmlPullParser.END_DOCUMENT) { switch (event) { ... |
Document | parseResponse(HttpResponse response) parse Response InputStream responseStream = response.getEntity().getContent();
DocumentBuilder xmlBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
return xmlBuilder.parse(responseStream);
|
String | parseTagValue(String xml, String tag, String endTag) This method parse the xml tag value. String val = ""; try { int index1 = xml.indexOf(tag) + tag.length(); int index2 = xml.indexOf(endTag, index1); if (index1 > -1 && index2 > -1) { val = xml.substring(index1, index2); } catch (Throwable thrown) { ... |
String | ReadCityCode(Context context, String cityname) Read City Code String returnString = ""; DocumentBuilderFactory docBuilderFactory = null; DocumentBuilder docBuilder = null; Document doc = null; try { docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilder = docBuilderFactory.newDocumentBuilder(); doc = docBuilder.parse(context.getAssets().open("citys.xml")); ... |
Document | XMLfromString(String xml) XM Lfrom String Document doc = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { dbf.setCoalescing(true); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); doc = db.parse(is); ... |