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?

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top