Boost C++ Libraries: Ticket #8095: Invalid XML is produced by write_xml when there is a special character in the key https://svn.boost.org/trac10/ticket/8095 <p> I have the following property tree, dumped in INFO format: </p> <pre class="wiki">CudbAppServiceId=1 { userLabel "" sqlAppSrvPlSchema identities-pl.sql CudbAppServiceId CudbAppServiceId=1 } </pre><p> When I dump it in XML format, I got the following: </p> <pre class="wiki">&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;CudbAppServiceId=1&gt; &lt;userLabel/&gt; &lt;sqlAppSrvPlSchema&gt;identities-pl.sql&lt;/sqlAppSrvPlSchema&gt; &lt;CudbAppServiceId&gt;CudbAppServiceId=1&lt;/CudbAppServiceId&gt; &lt;/CudbAppServiceId=1&gt; </pre><p> This is not a valid XML, because we have a tag "<a class="missing wiki">CudbAppServiceId</a>=1". Of course, any other xml parser like xmllint will fail to parse it, because of the equality sign in the tag. </p> <p> Is there any solution to this problem? Like somehow emitting &amp;#61; instead of the raw '=' inside the tag and in the text? </p> <p> This is a possible problem in 1.53 as well, since property tree was not updated. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8095 Trac 1.4.3 Sebastian Redl Thu, 22 Jan 2015 15:55:49 GMT <link>https://svn.boost.org/trac10/ticket/8095#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8095#comment:1</guid> <description> <p> There is no solution that will turn your data into valid XML. Element names must follow the Name production, which cannot contain entity references. </p> <p> The best I can do is fail validation when writing the XML, so that you don't end up with invalid documents. </p> </description> <category>Ticket</category> </item> <item> <author>smr@…</author> <pubDate>Fri, 23 Jan 2015 19:37:21 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/8095#comment:2 https://svn.boost.org/trac10/ticket/8095#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">smr@…</span> added </li> </ul> Ticket Gray Wolf <wolf+"https://svn.boost.org"@…> Sat, 30 Jun 2018 09:17:12 GMT version changed https://svn.boost.org/trac10/ticket/8095#comment:3 https://svn.boost.org/trac10/ticket/8095#comment:3 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.52.0</span> → <span class="trac-field-new">Boost 1.67.0</span> </li> </ul> <p> I've hit another edge case today when converting bunch of .info to .xml. In my case the issue was empty key (since this is valid in info format): </p> <blockquote> <p> "" value </p> </blockquote> <p> but produces </p> <blockquote> <p> &lt;&gt;value&lt;/&gt; </p> </blockquote> <p> in xml. </p> <p> I think failing the generation with an exception would be best (and only) solution. Sure, I can (and do now) re-read the xml after <code>pt::write_xml()</code> and validate it but feels like unnecessary, since I can't imagine when the invalid xml would be actually useful (since not even property_tree can read it back, correct?). </p> Ticket Gray Wolf <wolf+"https:@…> Sat, 30 Jun 2018 09:20:05 GMT cc changed https://svn.boost.org/trac10/ticket/8095#comment:4 https://svn.boost.org/trac10/ticket/8095#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">wolf+"https:@…</span> added </li> </ul> Ticket