Android: parse XML from string problems

Here is one example i hope it will be usefull to understand “SAXParser” package test.example; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.TextView; public class XMLParsingDemo extends Activity { private final String MY_DEBUG_TAG = “WeatherForcaster”; … Read more

Merging xml file using java NodeList

In order to do that on your own. You should do this following : public static void mergeXML(){ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; Document doc = null; Document doc2 = null; try { db = dbf.newDocumentBuilder(); doc = db.parse(new File(“D:\\Loic_Workspace\\Test2\\res\\test.xml”)); doc2 = db.parse(new File(“D:\\Loic_Workspace\\Test2\\res\\test2.xml”)); NodeList ndListFirstFile = doc.getElementsByTagName(“staff”); Node nodeArea = doc.importNode(doc2.getElementsByTagName(“area”).item(0), … Read more