[xml] Problem with XML output formatting



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

        Hello!
        I want to parse an existing XML document. Here is how the XML should
look like:

<options>
    <general>
        <value1>some text</value1>
        <value2>another text</value2>
        <value3>another text 2</value3>
    </options>
</general>

        I remove a node in this way (node is pointing to "general" node):

if ( !xmlStrcmp( node->name, (const xmlChar*)"value2") )
{
        xmlNodePtr node_to_del = node;
        node = node->next;
        
        xmlUnlinkNode( node_to_del );
        xmlFreeNode( node_to_del );
        
        continue;
}

        But when I save the file with xmlSaveFormatFile( CONF_FILE, doc, 1 ) a
blank line appears:

<options>
    <general>
        <value1>some text</value1>
        
        <value3>another text 2</value3>
    </options>
</general>

        I'm inserting a new node in this way (orig_node is same as node):

xmlNewChild( orig_node, NULL, (const xmlChar*)"value4", (const
xmlChar*)"Just another text" );

        And here is the result in saved file:

<options>
    <general>
        <value1>some text</value1>
        
        <value3>another text 2</value3>
    <value3>another text 2</value3></options>
</general>

        There is no problem to parse and edit the file in my program. But I'm
trying to make a config file and it is possible someone to edit it so I
want to make an ordered output.
        What is wrong with my code?
        Thanks in advance!

        Best regards,
        Petyo Milotinov
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDMY06H/3eKQaFKT0RAiOeAJ46IVAyOQLgY3v61KQGYI3TcdHLGwCfXSCB
V3P5XtI9Ka0oKE/SpsUxUvY=
=cSxM
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]