Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think it is better to use SAX for parsing an XML this is an example of parsing:</p> <p>You need to create a class parser like this: </p> <pre><code> { public class DataXMLReader extends DefaultHandler { public DataXMLReader() { } public void startElement(String uri, String name, String qName,Attributes atts) { if (name.trim().equalsIgnoreCase("window")) { atts.getValue("type_id") // to get proprietis } else if (name.trim().equalsIgnoreCase("component")) { } } public void endElement(String uri, String name, String qName) throws SAXException { if (name.trim().equalsIgnoreCase("component")) { if(Integer.parseInt(typeid)&lt;=6) idParent.remove(idParent.size()-1); } } @Override public void startDocument() throws SAXException { // TODO Auto-generated method stub super.startDocument(); Log.e("StartDoc","Reading XML"); } public void endDocument() throws SAXException { // TODO Auto-generated method stub myBdd.close(); Log.e("EndtDoc","End XML"); } } } </code></pre> <p>and this is an example to call XML from URL:</p> <pre><code>String url="http://vxbfdhbf.xml"; try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); URL sourceUrl = new URL(url); HttpURLConnection connection = null; connection = (HttpURLConnection)sourceUrl.openConnection(); connection.setConnectTimeout(60000); connection.setInstanceFollowRedirects(false); connection.connect(); DataXMLReader myXMLHandler = new DataXMLReader(this,"1"); xr.setContentHandler(myXMLHandler); xr.parse(new InputSource(connection.getInputStream())); connection.disconnect(); } catch (Exception e) { Log.e("saxERR",""+e.toString()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload