Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

It's very much part of the philosophy of XML that the responsibility of getting the content right rests with the producer and not the consumer. That's because it's far easier and cheaper to generate correct XML than to repair bad XML; and there are a lot more people reading XML than writing it. If you find yourself lumbered with XML (or rather non-XML) produced by someone who was ignorant of this attitude to quality, you've therefore got a tough problem.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top