Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
sara84
Posts: 43
Registered: ‎08-23-2008

Reading and writing the XML (local)

Hi

 

I wolud like to know how the XML is created on the local device.

And also i would like to know the reading /writing /updating the xml.

 

Is XML is permanent storing place in the device?

 

Code support is appriciated.

 

Please use plain text.
Developer
marchywka
Posts: 1,415
Registered: ‎07-30-2008

Re: Reading and writing the XML (local)

There is no file system on earlier devices but there is a persistent store. XML is just text, AFAIK, there is

no magical XML land. RIM does provide some XMLParser classes ( and again I personally recommend rendering

all the javadoc html and putting it in a location that can be easily grepped so you can look for keywords like

XML without the "Assistance" of a GUI or browser). I would imagine that XMLWriter would work for you.

 

http://www.google.com/search?hl=en&q=Xmlwriter+site%3Ablackberry.com&btnG=Search

 

http://www.google.com/search?hl=en&q=xmlparser++site%3Ablackberry.com

 

I did get this to run with a subclass of DefaultHandler but I was trying to parse html which didn't work too well (duh).

 

http://www.blackberry.com/developers/docs/4.1api/org/xml/sax/helpers/DefaultHandler.html

 

 

the commented out code is pretty much what you would expect,

( assumed I could find something similar to XMLParser that works for real-life html )

 //XMLParser xml = new XMLParser();
   //DefaultHandler dh= new htmlhandler(m_app);
   //xml.parse(in,dh)

 

class htmlhandler extends DefaultHandler
{
 MyTgtApp m_app;
 String m_data="nothing";
 String xdata="";
 public htmlhandle(MyTgtApp app) {super(); m_app=app; }
 public void endElement(String url,
  String local, String qName ) throws SAXException
  
 {  }
 public void processingInstruction(String target,
                                  String data)
                           throws SAXException
    {
     xdata=target+" "+data+"\n\r";
     m_data+=xdata;
       }
 public void endDocument()
                 throws SAXException
     {m_app.saysomething("parse done "+m_data.length()+xdata);
     }
}

 

 

 

 

Please use plain text.