Set text to an Element XML

13 views
Skip to first unread message

pyth...@gmail.com

unread,
Jun 3, 2019, 1:26:33 PM6/3/19
to CodenameOne Discussions
Hi,
I try to generate a XML file and I want to set text to an Element XML like this :

 Element root= new Element("root");
 Element name= new Element("name",true);           
 name.setText("Toto");
 root.addChild(name);
 ....


But the tag "name" removed and the text put to the tag "root".

Any idea ?

Thanks.

Shai Almog

unread,
Jun 4, 2019, 12:33:47 AM6/4/19
to CodenameOne Discussions
Hi,
how is the XML printed?
Are you using XMLWriter?

pyth...@gmail.com

unread,
Jun 4, 2019, 3:24:38 AM6/4/19
to CodenameOne Discussions
Yes i use XML Writer.
The XML printed is :

<root>Toto</root>

While I wait for :

<root>
<name>Toto </name>
</root>

Thanks

Shai Almog

unread,
Jun 4, 2019, 11:42:33 PM6/4/19
to CodenameOne Discussions
Text elements are blank in DOM their name is hidden. You need to add a name element and then within it add a text element.
This is done to enable syntax such as:

<name>to<br/>do</name>
Reply all
Reply to author
Forward
0 new messages