Search code examples
xmlboostboost-propertytree

read_xml() throw exception due to lacking of double quotes


I use boost::property_tree object to parse xml like this:

<?xml version="1.0" encoding="utf-8"?>
<root>
    <node attr="attr_str"/>
</root>

When I call read_xml() to parse this content, it works well. But if I remove those double quotes around the attr attribute like this:

<?xml version="1.0" encoding="utf-8"?>
<root>
    <node attr=attr_str/>
</root>

It throw the xml_parse_error exception.

Does any flags can be set to ignore the checking of double quotes?


Solution

  • XML Attributes must be quoted:

    http://www.w3schools.com/xml/xml_attributes.asp

    You're going to need to include those quotes - otherwise it is invalid markup.