List Info

Thread: Writing xmlNodePtrs out with xmlSaveTree




Writing xmlNodePtrs out with xmlSaveTree
user name
2006-09-29 17:56:35
I have a couple of questions on writing out an XML element
and its
children with xmlSaveTree:

First, is there any easy way to tell xmlSaveTree to write a
line break
after completing a node - so that things get written out
like

<foo>blah</foo>
<foo>bar</foo>

rather than

<foo>blah</foo><foo>bar</foo>

Or do I just need to write it myself - and if so, is there a
simple way to
use the xmlSaveCtxtPtr to write the break?

Second:
Is there any way to force a given indention level, so that I
can start
writing a document (i.e. write the xml, DOCTYPE, and root
node), then
repeatedly call xmlSaveTree to write the sub-elements
properly indented
within the root node?

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Writing xmlNodePtrs out with xmlSaveTree
user name
2006-09-29 20:29:35
On Fri, Sep 29, 2006 at 12:56:35PM -0500, David Hagood
wrote:
> I have a couple of questions on writing out an XML
element and its
> children with xmlSaveTree:
> 
> First, is there any easy way to tell xmlSaveTree to
write a line break
> after completing a node - so that things get written
out like
> 
> <foo>blah</foo>
> <foo>bar</foo>
> 
> rather than
> 
> <foo>blah</foo><foo>bar</foo>

 No, spaces are significant in XML, in general you can't
ignore or 
add them randomly.

> Or do I just need to write it myself - and if so, is
there a simple way to
> use the xmlSaveCtxtPtr to write the break?

 Make a text node with a single cariage return and serailize
it.

> Second:
> Is there any way to force a given indention level, so
that I can start
> writing a document (i.e. write the xml, DOCTYPE, and
root node), then
> repeatedly call xmlSaveTree to write the sub-elements
properly indented
> within the root node?

 Again, no, spaces are significant, and while there is
support for indentation
for whole document there is no provision for single nodes.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )