hi
i am a beginer in j2me
i need to create an xml file
in j2me (on N6288)
can any one help my pls whit code for that ?
tanks
hi
i am a beginer in j2me
i need to create an xml file
in j2me (on N6288)
can any one help my pls whit code for that ?
tanks
hi this is mayur,
The concept of generating xml file if same in java. if you wanna use j2me you should do file handling in your code.
Below is code written in jsp, the only thing you need to modify is to replace the file writing command.
int iLf = 10;
char cLf = (char)iLf;
String xmlfile="path to your directroy/Data.xml";
File outputFile = new File(xmlfile);
outputFile.createNewFile();
FileWriter outfile = new FileWriter(outputFile);
outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
outfile.write("<Table>"+cLf);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from users");
while(rs.next())
{
outfile.write("<users>"+cLf);
outfile.write("<cid>" + rs.getString(1) +"</cid>"+cLf);
outfile.write("<cname>" + rs.getString(2) +"</cname>"+cLf);
outfile.write("<username>" + rs.getString(3) +"</username>"+cLf);
outfile.write("<password>" + rs.getString(4) +"</password>"+cLf);
outfile.write("<email>" + rs.getString(5) +"</email>"+cLf);
outfile.write("<cellno>" + rs.getString(6) +"</cellno>"+cLf);
outfile.write("<address>" + rs.getString(7) +"</address>"+cLf);
outfile.write("<city>" + rs.getString(8) +"</city>"+cLf);
outfile.write("<state>" + rs.getString(9) +"</state>"+cLf);
outfile.write("<zip>" + rs.getString(10) +"</zip>"+cLf);
outfile.write("<country>" + rs.getString(11) +"</country>"+cLf);
outfile.write("<question>" + rs.getString(12) +"</question>"+cLf);
outfile.write("<answer>" + rs.getString(13) +"</answer>"+cLf);
outfile.write("</users>"+cLf);
Mayur Dharukiya
M.B.A+B.E.+Diploma In Information Technology + SAP HR Consultant
Tata Consultancy Services Certified Java Developer
Brainbench Ceftified Java Developer Transcript ID is 6577305
htttp://www.ampleassociation.com
is that so ?
i understod i need to use an api to do write new file in j2me
what api do i need
a link for download for NOKIA 6288
will be wonderful
thanks
Hi,
there are many api for XML parsing available for J2ME environment - NanoXML, KXML, etc. With NanoXML, you can do this:
You will have:Code:kXMLElement element = new kXMLElement(); element.setTagName("root"); element.addProperty("key", "value"); kXMLElement child = new kXMLElement(); child.setTagName("child"); child.setContent("Teste"); element.addChild(child); kXMLElement child2 = new kXMLElement(); child2.setTagName("child"); child2.setContent("conteudo"); child2.addProperty("propriedade", "valoer"); element.addChild(child2);
Simple, doen't it?Code:<root KEY="value"> <child>Teste</child> <child PROPRIEDADE="valoer">conteudo</child> </root>
[]'s
thanks !!!
how do i save the element to be an XML file ?
i understand that it is element.write
but wat it the writer and how do i give him the file name
he takes java.io has parameter
Last edited by aaaabaaaa; 2008-10-30 at 11:30.
This will assist you :
http://www.devx.com/xml/Article/11773/0/page/1
Y
thanks but
that exsamel is for using an existing XML
i am trying to creat a new simpel XML file on my NOKIA 6288
by j2me
i have a problem in saving the
kNanoXML.kXMLElement element = new kNanoXML.kXMLElement();
element.setTagName("root");
element.addProperty("key", "value");
kNanoXML.kXMLElement child = new kNanoXML.kXMLElement();
child.setTagName("child");
child.setContent("Teste");
element.addChild(child);
kNanoXML.kXMLElement child2 = new kNanoXML.kXMLElement();
child2.setTagName("child");
child2.setContent("conteudo");
child2.addProperty("propriedade", "valoer");
element.addChild(child2);
the "element " to XML file
Writer writer=null ;
try
{
writer.write("c:\\aa.xml");
element.write(writer) ;
}
catch (Exception e)
{
System.out.println("problem in writeing XML file ----- " + e.toString());
}
nonworking
it run but ther is not a new file...
Hi
You need to Use File Connection API in J2Me to work with Files.
simple example to write files in J2me
Code:try { FileConnection fconn = (FileConnection)Connector.open("file:///CFCard/newfile.txt"); if (!fconn.exists()) fconn.create(); // create the file if it doesn't exist fconn.close(); } catch (IOException ioe) {
Y
Lets starts again mate...
Explain Properly your desired Wish.
Tip : use Bullets Points to Highlight each stage in your development.
Y
I want to crate a simpel XML file by j2me on my mobile N6288
after that i will want to send it over bluetooth to my PC
Ok,
1) http://www.devx.com/xml/Article/11773/0/page/1
2) Use RMS to store the XML( No Need to save the File over SD)
BT:
3) http://discussion.forum.nokia.com/fo...d.php?t=148525
Good Luck
Y