[property_tree] XML parser errors

Hey, This is not a new issue, but a quick search sees it not reported. Each of the XML parsers that are available for property_tree has a problem, with the exception of the TinyXML version (which is annoying because it requires an external lib). - RapidXML (the default) Lines 95 and 98 of xml_parser_read_rapidxml.hpp need to be changed from this: if (flags & no_comments) doc.parse<parse_normalize_whitespace>(&v.front()); else doc.parse<parse_normalize_whitespace | parse_comment_nodes>(&v.front()); to this: if (flags & no_comments) doc.template parse<parse_normalize_whitespace>(&v.front()); else doc.template parse<parse_normalize_whitespace | parse_comment_nodes>(&v.front()); Without this change gcc 4.2 won't compile them (not sure about other versions of gcc). - PugXML Line 1827 of pugxml.hpp looks like: class xml_iterator : public std::_Ranit<_Ty,_Diff,_Pointer,_Reference> I don't know about anyone else, but my STL doesn't have a _Ranit class, and depending on non-standard components is a bad idea for portable code. - Spirit It fails to parse some XML that is perfectly valid under the RapidXML and and TinyXML versions. On the plus side, it compiles out of the box ;) I'm not 100% sure what it is, I get this error: terminate called after throwing an instance of 'boost::property_tree::xml_parser::xml_parser_error' what(): <unspecified file>: invalid character entity Aborted Here is a trimmed down XML file that should work fine, and does under rapid and tiny: <log> <formatter type="literal" name="BEGIN"> <string>TEMP</string> </formatter> <appender type="file" name="FILE"> <filename>test.log</filename> <formatter>BEGIN</formatter> <truncate>true</truncate> </appender> <logger name="test"> <threshold>10</threshold> <appender>FILE</appender> </logger> <fallback>test</fallback> </log> I don't see anything specifically wrong with this. Note however, that using spirit on a DIFFERENT xml file that imho is significantly more complex and larger parses just fine with spirit (I would paste it, but it >2.5k). PreZ :)

On Thu, 03 Jul 2008 22:02:46 +0000, Preston A. Elder wrote:
- Spirit
terminate called after throwing an instance of 'boost::property_tree::xml_parser::xml_parser_error' what(): <unspecified file>: invalid character entity Aborted
I figured this one out, sorry. First, the XML I posted in the previous post parses just fine, but my app wasn't picking up the file (damn hard-coded filenames :P). The original file is failing to parse because I have things like: <prefix>[</prefix> In there. The spirit parser doesn't handle ... To be more correct, the exception is thrown by line 85 of xml_parser_utils.hpp, which on quick inspection, doesn't support '#' (or by extension #x). This is the root of the problem, as I noticed in the spirit parsing file, it DOES infact define what to do with num; tokens. So basically the parser utils has to be updated to support num; and such. Sorry for the confusion. PreZ :)
participants (1)
-
Preston A. Elder