Back to project page mobcomp-httpclient.
The source code is released under:
Written by: Markus Tacker <m@coderbyheart.de> | http://coderbyheart.de/ Copyright (c) Markus Tacker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and ...
If you think the Android project mobcomp-httpclient listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package de.hsrm.mi.mobcomp.httpclientdemo.flickr; /*w w w .j ava 2s . c o m*/ import java.io.ByteArrayInputStream; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import android.util.Log; /** * Parst eine flickr-XML-Antwort mit einem Frob * * @author Markus Tacker <m@coderbyheart.de> */ public class FrobReader extends XmlReader { public String getFrob(String xmlData) { String frob = null; DocumentBuilderFactory domBuilderFactory = DocumentBuilderFactory .newInstance(); domBuilderFactory.setIgnoringElementContentWhitespace(true); try { DocumentBuilder builder = domBuilderFactory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xmlData .getBytes())); NodeList frobNodes = doc.getElementsByTagName("frob"); Node frobNode = frobNodes.item(0); frob = getTextValue(frobNode); } catch (SAXException e) { Log.e(getClass().getCanonicalName(), e.getMessage()); } catch (ParserConfigurationException e) { Log.e(getClass().getCanonicalName(), e.getMessage()); } catch (IOException e) { Log.e(getClass().getCanonicalName(), e.getMessage()); } return frob; } }