Re: [xml] XML output formatting

On Wed, Mar 20, 2002 at 11:38:06AM -0500, Wei Qin wrote:

I am generating an XML file with libxml2. I use xmlSaveFile(). But There
is no line break on the output. Do I have to create text node in the tree
with "\n" so as to see the line breaks? Or is there some auto-format
utilities that I can use?


You can use xmllint --format

paphio:~/XML -> cat tst.xml 

paphio:~/XML -> ./xmllint --format tst.xml 
<?xml version="1.0"?>
paphio:~/XML -> 
At the C level you need to either:
      xmlIndentTreeOutput = 1;
    or call

to have indentation and not just line break added.
Note also that libxml2 will not indent or add linebreak within elements
which are mixed content.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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