-1

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?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
naive231
  • 1,360
  • 1
  • 11
  • 28
  • 1
    The document, without double quotes around the value of `attr`, is not valid XML. Why do you expect (and want) an XML parser to parse invalid XML? – Thanatos May 15 '12 at 03:31
  • I know your point. But my project had some xml files with these mess things already, so I'm trying to make my parser to be compatible with them. – naive231 May 15 '12 at 05:17

2 Answers2

0

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.

sirmdawg
  • 2,579
  • 3
  • 21
  • 32
0

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.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164