Boost C++ Libraries: Ticket #5211: XML output of arrays https://svn.boost.org/trac10/ticket/5211 <p> The XML writer of the property_tree is not generating valid XML if an attribute in a node is a list of values. { </p> <blockquote> <p> "numbers" : [ </p> <blockquote> <p> "one", "two", "three", "four" </p> </blockquote> <p> ] </p> </blockquote> <p> } the xml generated for this looks like: &lt;numbers&gt; &lt;&gt;one&lt;/&gt;&lt;&gt;two&lt;/&gt;&lt;&gt;three&lt;/&gt;&lt;&gt;four&lt;/&gt; &lt;/numbers&gt; </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5211 Trac 1.4.3 Christian Ceelen <christian.ceelen@…> Tue, 22 Feb 2011 17:30:21 GMT <link>https://svn.boost.org/trac10/ticket/5211#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5211#comment:1</guid> <description> <p> sorry for the formating mess above. </p> <p> The XML writer of the property_tree is not generating valid XML if an attribute in a node is a list of values. </p> <pre class="wiki">{ "numbers" : [ "one", "two", "three", "four" ] } </pre><p> the xml generated for this looks like: </p> <div class="wiki-code"><div class="code"><pre><span class="nt">&lt;numbers&gt;</span> <span class="err">&lt;</span>&gt;one<span class="err">&lt;</span>/&gt;<span class="err">&lt;</span>&gt;two<span class="err">&lt;</span>/&gt;<span class="err">&lt;</span>&gt;three<span class="err">&lt;</span>/&gt;<span class="err">&lt;</span>&gt;four<span class="err">&lt;</span>/&gt; <span class="nt">&lt;/numbers&gt;</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>Sebastian Redl</dc:creator> <pubDate>Fri, 14 Feb 2014 14:39:57 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5211#comment:2 https://svn.boost.org/trac10/ticket/5211#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> PTree has no notion of "attribute in a node" or "list of values". It has nodes with data and named children, where the name can be empty. </p> <p> As such, its match against various existing formats is imperfect. </p> <p> Your JSON fragment is translated by the JSON parser into a root node with one named child, "numbers", which in turn has four named children, all with the empty name. Neither root nor its child have data; the four leaf nodes have the strings from the JSON array as data. </p> <p> The XML mapping of PTree generates an element for every named child, with the element name being the name of the child. Since something empty isn't a valid name, nodes with the empty name aren't supported by the PTree XML mapping. </p> <p> In my ongoing docs improvement project, I will document the restrictions of each mapping more closely, and then implement software checks while writing to make sure nothing invalid is generated. But unnamed children won't be supported for XML writing. </p> Ticket