Re: [xml] Avoiding emediate close of elements



On Wed, Oct 07, 2009 at 09:24:44AM -0300, Darko Miletic wrote:

Martin Olsen wrote:
On Wednesday 07 October 2009 13:07:41 you wrote:
  
Use xmlTextWriterStartElement or xmlTextWriterStartElementNS with
xmlTextWriterFullEndElement
    
Thanks! Unfortunately, I still get the same result.

Here's the smallest code to reproduce:
    writer = xmlNewTextWriterDoc( &doc, 0 );
    xmlTextWriterStartDocument( writer, NULL, "UTF-8", NULL );
    xmlTextWriterStartElement( writer, BAD_CAST "element" );
    xmlTextWriterFullEndElement( writer );
    xmlTextWriterEndDocument( writer );
    xmlSaveFile( "-", doc );

Any other suggestions?
  

Just add empty space in the tag. That will force the <tag></tag>

 The xmlsave.h API have a XML_SAVE_NO_EMPTY flagwhich will do this but
I don't know how this could be forced at the xmlwriter level.
Note that for an XML parser the two syntax are strictly equivalent
so you're generating XML for a client which doesn't use an XML parser
for handling it (with the exception of Microsoft XMLReader API which
distinguish the two but really should not),

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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