parsing - Removing tags from xml file for BlackBerry -


i developing blackberry app needs read xml file. able read remove tags such <?xml version='1.0' encoding='utf-8'?>, <feed>, <author> , on...

i'm using blackberry 9800 simulator.

have checked file atom 1.0 file. how should remove these tags?

currently codes of got internet. displays 'id' , 'updated' date of file. how can display/filter data away , remove tags?

thanks, hend

 class myapp extends uiapplication{ //creating member variable mainscreen mainscreen _screen= new mainscreen(); //string variables store values of xml document string _node,_element; connection _connectionthread;  public static void main(string arg[]){     myapp application = new myapp();     //create new instance of application     //and start application on event thread     application.entereventdispatcher(); }  public myapp() {     _screen.settitle("xml parsing");//setting title     _screen.add(new richtextfield("requesting....."));     _screen.add(new separatorfield());     pushscreen(_screen); // creating screen     //creating connection thread run in background     _connectionthread = new connection();     _connectionthread.start();//starting thread operation }  public void updatefield(string node, string element)  {         synchronized (uiapplication.geteventlock())      {         string title = "my app";         _screen.add(new richtextfield(node + " : " + element));         if (node.equals(title))         {             _screen.add(new separatorfield());             }         }     }    private class connection extends thread{     public connection(){         super();     }      public void run(){         // define variables later used parsing          document doc;         streamconnection conn;          try{             //providing location of xml file,             //your address might different             conn=(streamconnection)connector.open               ("http://www.google.com");             //next few lines creates variables open             //stream, parse it, collect xml data ,             //extract data required.             //in case elements,             //node , values of element             documentbuilderfactory docbuilderfactory               = documentbuilderfactory. newinstance();              documentbuilder docbuilder               = docbuilderfactory.newdocumentbuilder();              docbuilder.isvalidating();             doc = docbuilder.parse(conn.openinputstream());             doc.getdocumentelement ().normalize ();             nodelist list=doc.getelementsbytagname("*");             _node=new string();             _element = new string();             //this "for" loop used parse through             //xml document , extract elements ,             //value, can displayed on device              (int i=0;i<list.getlength();i++){                 node value=list.item(i).                   getchildnodes().item(0);                 _node=list.item(i).getnodename();                 _element=value.getnodevalue();                 updatefield(_node,_element);             }//end         }//end try         //will catch exception thrown xml parser         catch (exception e){             system.out.println(e.tostring());          }       }//end connection function   }// end connection class }//end xml_parsing_sample 

create method same run() searching tagname. allows info several tags read , displayed.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -