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

Native Development

Posts: 196
Registered: ‎12-14-2009
My Device: Not Specified

Saving XML file with attributes

I want to add to an XML file structured like this.


  <column loop="true">
    <item2  color="#4d6862"  />
    <item2  color="#ff0000ff" />
    <item2  color="#ff00ff00" />
    <item2 color="#ff00ffff" />
    <item2 color="#ffff0000" />
    <item2 color="#ffff00ff" />
    <item2  color="#ffffff00" />
    <item2 color="#4d6862" />



I see adding attributes is tricky as the docs say. How can I add another "item2" item with a color attribute to an existing XML file? 


I know I'll use save from:




but they do say

"Note that the save-to-XML support in this version has some serious limitations since the XML output is well-formed (based on the rules of XML markup) but it is not necessarily valid since it does not conform to any schema definition. In particular the choice of whether to output character data as an attribute (name="value") or as an element (<name>value</name>) is not under the developer's control and is based on some simple but arbitrary rules."


Is it possible to do so?




Posts: 17,006
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Saving XML file with attributes

you could use the QtXml api, it offers a broader set of features.
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter