c++tinyxml2

Why is tinyxml2 failing to parse a Traffic Server xml file?


Using tinyxml2, I'm trying to parse this Traffic Server config file:

<LogFormat>
    <Name = "simple"/>
    <Format = "simple"/> 
</LogFormat>

<LogObject>
     <Format = "simple"/>
     <Filename = "simple.log"/>
     <Mode = "ascii"/> 
</LogObject>

Traffic server XML config format is described here:

LoadFile() gives me this error:

"Error=XML_ERROR_PARSING_ELEMENT ErrorID=6 (0x6) Line number=2"

What is wrong with the Name element? Can tinyxml2 simply not parse Traffic Server XML config files?


Solution

  • <Name = "simple"/> is not a valid XML element. Valid XML element is something like

    <LogFormat>
        <Name value="simple"/>
        <Format value="simple"/> 
    </LogFormat>
    

    or

    <LogFormat name="simple" format="simple"/> 
    </LogFormat>
    

    Thus Traffic server logs_xml.config config file is not in the XML format, and tinyxml cannot parse it.