Menu

Save-formatting when using CDATA blocks

John
2010-10-06
2024-08-26
  • John

    John - 2010-10-06

    If I have this test code:

        TiXmlElement *parentElem = new TiXmlElement("ParentNode");
        TiXmlElement *newElem = new TiXmlElement("TestNode");
        TiXmlText *textElem = new TiXmlText("Test Content");
        //textElem->SetCDATA(true);
        newElem->LinkEndChild(textElem);
        parentElem->LinkEndChild(newElem);
    

    With the line commented I get output XML:

    <ParentNode>
        <TestNode>Test Content</TestNode>
    </ParentNode>
    [/code
    ]Uncommenting the line I get:
    [code]<ParentNode>
        <TestNode>
            <![CDATA[Test Content]]>
    </TestNode>
    </ParentNode>
    [/code]
    Now ideally it would still all be one line, but I don't really mind it putting the CDATA content nested... but the fact indentation is screwed up on the closing [i]<TestNode>[/i] is a pain. Is this a controllable part of TinyXml, or a bug, or just the way it is?
    
     
  • John

    John - 2010-10-06

    Grr, formatting typo. No editing possible? Hopefully it's still clear.

     
  • Lee Thomason

    Lee Thomason - 2010-10-06

    That's a bug, albeit a minor one. TiXmlPrinter may work around the problem - it uses a different output path.

     
  • KG Bernad

    KG Bernad - 2024-08-26

    Yeah, as of my experience it's only a bug and vanish soon. We offer facing such kind of situations dealing with our free computer antivirus website. Thanks

     

Log in to post a comment.