tags:

views:

22

answers:

1

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>

Uncommenting the line I get:

<ParentNode>
    <TestNode>
        <![CDATA[Test Content]]>
</TestNode>
</ParentNode>

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 <TestNode> is a pain. Is this a controllable part of TinyXml, or a bug, or just the way it is?

A: 

Looks like a bug in the output formatting if TinyXML.

It may work to use TiXmlPrinter for output instead of the TiXmlDocument output (which I assume you are using?). TiXmlPrinter uses a different print path, and may not have the same bug.

grinliz