java - Unable to parse xml with different vale of name in android -
my xml code this:-
<mmp> <script id="tinyhippos-injected"/> <merchant> <response> <url>https://www.google.com</url> <param name="ttype">nbfundtransfer</param> <param name="temptxnid">650398</param> <param name="token">7ohxxw7ndm0ft%2b02bkgihb0n0ekameia2oeajwtjis</param> <param name="txnstage">1</param> </response> </merchant> </mmp>
here want value of token , txnstage
and android code :-
try { url url = new url(url1); documentbuilderfactory dbf = documentbuilderfactory .newinstance(); documentbuilder db = dbf.newdocumentbuilder(); // download xml file doc = db.parse(new inputsource(url.openstream())); doc.getdocumentelement().normalize(); // locate tag name nodelist = doc.getelementsbytagname("response"); (int temp = 0; temp < nodelist.getlength(); temp++) { node nnode = nodelist.item(temp); if (nnode.getnodetype() == node.element_node) { element eelement = (element) nnode; // set texts textviews item nodes // title textview.settext(textview.gettext() + "title : " +eelement.getattribute("name") + "\n" + "\n"); } } } catch (exception e) { log.e("error", e.getmessage()); e.printstacktrace(); }
using code i'm not getting value in textview. have idea, please share
it looks nodelist
collection contains 1 item - representing <response>
element. element not have attribute name
set - nothing gets populated.
Comments
Post a Comment