[codenameone-discussions] Re: Generate XML file with XMLWriter

2019-04-11 Thread Shai Almog
Try this: 

try(OutputStream os = 
FileSystemStorage.getInstance().openOutputStream(path+""+"test.xml");  
OutputStreamWriter writer = new OutputStreamWriter(os)) {
xw.writeXML(writer, root);
writer.close();
} catch(IOException err) {
Log.e(err);
}

It looks like your code closes the output stream instead of the writer. 
This can discard unflushed bytes.

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/3536d5f9-83b2-407d-b8aa-d5cc41f9b812%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[codenameone-discussions] Re: Generate XML file with XMLWriter

2019-04-11 Thread pythoudk
Yes, I want to create an XML file and save it to the phone. For the moment, 
it is saved in the .cn/ repertory of my PC and when I open it for check, it 
is empty and no tag is there

On Thursday, April 11, 2019 at 4:14:09 AM UTC+2, Shai Almog wrote:
>
> Both methods lead to the same block: 
> https://github.com/codenameone/CodenameOne/blob/master/CodenameOne/src/com/codename1/xml/XMLWriter.java#L180-L242
>
> I'm guessing the problem you are experiencing is in reading the XML.
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/de673086-3ba4-448e-ad7d-35ce95206752%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[codenameone-discussions] Re: Generate XML file with XMLWriter

2019-04-10 Thread Shai Almog
Both methods lead to the same block: 
https://github.com/codenameone/CodenameOne/blob/master/CodenameOne/src/com/codename1/xml/XMLWriter.java#L180-L242

I'm guessing the problem you are experiencing is in reading the XML.

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/1a43410d-d2e2-49b6-9d95-aeb4b6e4f889%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[codenameone-discussions] Re: Generate XML file with XMLWriter

2019-04-10 Thread pythoudk
Yes it works.

But how to generate XML file and write tag into with XMLWriter ? 
With my code and toXML() method, that isn't work.

On Tuesday, April 9, 2019 at 8:46:18 PM UTC+2, pyth...@gmail.com wrote:
>
> Hi, 
> I have some problems to generate an XML file, the file is created but the 
> root tag is not written into the file when I call the writeXML(writer, 
> root) method;
>
> Here is the code :
>
> try{
> //Element root
> Element root = new Element("root");
> String path = FileSystemStorage.getInstance().getAppHomePath();
> XMLWriter xw = new XMLWriter(false); 
> OutputStream os = 
> FileSystemStorage.getInstance().openOutputStream(path+""+"test.xml");
> OutputStreamWriter writer = new OutputStreamWriter(os);
> xw.writeXML(writer, root); 
> os.close();
> writer.close();
>
> }catch(){
>.
> }
>
> Any idea ? 
> Thank you.
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/d26a28d1-afba-4041-bc7a-a285c8f0cd86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[codenameone-discussions] Re: Generate XML file with XMLWriter

2019-04-09 Thread Shai Almog
I just tried this:

Form hi = new Form("XML", BoxLayout.y());
Button write = new Button("Write");
hi.add(write);
write.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent evt) {
Element root = new Element("root");
XMLWriter xw = new XMLWriter(false);
Log.p(xw.toXML(root));
}
});

hi.show();


It printed out:
 

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/1eda42ea-1fae-4461-829d-1999dc36b5b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.