how to Parse a local XML file in android? -


I am working on an Android project, and I can not parse a local file (raw / file .xml) . I have tried some suggestions which I have found on the internet but it is useless. This works when I try to parse a file in the net (using the URL class ...), but when I work with a local file program does not work !!! Please I need help (I use the SAC as the XML parser)

I enter the line URL sourceUrl = new URL ("example.com/w ...";); Changing the input code from to = new input source (getResources (). OpenRawResource (R.raw.example));

and line xr.parse (new InputSource (sourceUrl.openstream ())); with xr.parse (new input source (is.getByteStream ()));

  You can insert the XML file path here and internal Nodes USLN Self-Loop Can loop parsing. Save the value accordingly to each node in the array. Nodelist eNodeList = null; ENodeList = Utils.getXMLFromFilePath (your.xml "," firstNOdeName ", eNodeList); getElementsByNodelist (e-Nodlist) private static Jaoilements Beyodelist (Nodlalist Nodelist) {if (Nodelist! = NULL) {for (int i = 0; i & lt; nodelist.getLength (); I ++) {element element = (element) Nodlalistkitm (i); string id = GetTextValue (element, "id"); // attribute value element.getAttribute ( "attributename" ) of the; // If you want tjis element to parse again NodeList L = element.getElementsByTagName ( "innerTag"); // own loop getElementsByNodelist (L);}}} public static string getTextV alue (element elephant, string tagname) {string textVal = ""; NodeList nl = Ele.getElementsByTagName (tagName); if (nl! = Null & amp; nl.getLength () & gt; 0) {element l = (Element ) Nlkaitm (0); if (Elkgetforstcild ()! = null) {Tekstwal = Elkgetforstcild (). Getnodevlua ();}} return Tekstwal;}    

Comments