Hi everyone! can anyone share a very very simple complete code that creates and writes into an xml file a root node and one child element using kxml? please? I need it as my reference.. thanks
Hi everyone! can anyone share a very very simple complete code that creates and writes into an xml file a root node and one child element using kxml? please? I need it as my reference.. thanks
kXML is a parser for XML, not a generator. It's only for reading XML. To write, you have to construct the XML yourself.
I know of no XML generation library for Java ME.
Graham.
yeah.. I have my generated xml files placed on my phone but is it possible to insert and remove nodes and elements inside?
you would need a dom library or something alike. i suggest you either use a transition data model in which you insert/remove elements before you format the xml, or that you use another format. JSON would be quite indicated for that.
kXML 2 is very complete and contains not only Pull but DOM as well. I recommend to go out for a book about XML. Then have a look at the API of kXML again. If you understand XML, kXML is rather intuitive and allows you to create your files as well.
If you just append text at the start and end of your XML file, write the new start to an OutputStream, write the XML to that OutputStream, and write the new end to that OutputStream.
binsint, looking at all your various threads, I wonder if you need that at all: Who requires you to have an element root around of your XML? Who requires you to have a XML declaration? Yes, why do you deal with XML at all?
Last edited by traud; 2011-01-26 at 13:39.