I used xmlSaveFile("file.xml", docTree); This just dumps the xmlDocPtr
docTree to "file.xml"
without any indentation. Is there any options in libxml2 to set it properly.Thanks Senthil On 3/7/08, Stefan Behnel <[EMAIL PROTECTED]> wrote: > > Hi, > > Senthil Nathan *top-posted*: > > On Thu, Mar 6, 2008 at 11:33 PM, Stefan Behnel <[EMAIL PROTECTED]> > wrote: > >> Senthil Nathan wrote: > >>> I tried using the xmlCopyDocNode( ) and xmlCopyNode( ). It copies the > >> node > >>> but the indentation is not proper. > >> There is no indentation in an XML tree, but there may be text nodes > that > >> contain whitespace. Maybe you didn't copy those? > >> > >> > >>> How can we set the indentation in libxml2? > >> What are you trying to do? > > > > That's true. But when I dump the tree to a file, the indentation is not > > proper. > > All the nodes that I copied are just continuous. > > > > The xml file generated after dumping from libxml2 with few nodes added > or > > copied, > > <root> > > <level1> > > <level2></level2><level21></level21><level22></level22> > > </level1> > > </root> > > Ok, so what are you doing to serialise this result? Are you using the > "format" > option? That will not always give you the expected result, as libxml2 > cannot > easily distinguish between "ignorable" and meaningful whitespace. > > Two options: > > - parse with the XML_PARSE_NOBLANKS option to remove whitespace > > - copy the whitespace text nodes when you copy the element nodes > > Stefan >
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
