Avoiding emediate close of elements

View: New views
5 Messages — Rating Filter:   Alert me  

Avoiding emediate close of elements

by Martin Olsen-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

How can I force xmlwriter to not close empty elements emediately? What I want
is "<element></element>" not "<element/>". Is this possible?

I'm using xmlwriter from libxml-2.7.3.

--
Yours sincerely,
 TOP-TOY A/S
 Martin Olsen, IT-Systemdeveloper
 Telephone   +45 4616 3710
 Facsimile   +45 4616 3681
All information in this e-mail and all transactions are subject to
TOP-TOY's standard terms and conditions:
http://www2.top-toy.com/Start?SuccTPL=legal_notice
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@...
http://mail.gnome.org/mailman/listinfo/xml

Re: Avoiding emediate close of elements

by Mickautsch, Alfred :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Use xmlTextWriterStartElement or xmlTextWriterStartElementNS with xmlTextWriterFullEndElement


Servus -- Alfred

--
Alfred Mickautsch

SCHULER Business Solutions AG
Karl-Berner-Str. 4
72285 Pfalzgrafenweiler
Deutschland
Tel:    +49 7445 830-184
Fax:    +49 7445 830-349
E-Mail: alfred.mickautsch@...
Web:    www.schuler-ag.com

SCHULER Business Solutions AG
Aktiengesellschaft mit Sitz in D-72285 Pfalzgrafenweiler, Karl-Berner-Str. 4
Registergericht Stuttgart HRB 430947
Vorstand: Uwe Jonas, Harald Sieber
Vorsitzender des Aufsichtsrates: Achim Gauß

-----Ursprüngliche Nachricht-----
Von: xml-bounces@... [mailto:xml-bounces@...] Im Auftrag von Martin Olsen
Gesendet: Mittwoch, 7. Oktober 2009 11:40
An: xml@...
Betreff: [xml] Avoiding emediate close of elements

How can I force xmlwriter to not close empty elements emediately? What I want
is "<element></element>" not "<element/>". Is this possible?

I'm using xmlwriter from libxml-2.7.3.

--
Yours sincerely,
 TOP-TOY A/S
 Martin Olsen, IT-Systemdeveloper
 Telephone   +45 4616 3710
 Facsimile   +45 4616 3681
All information in this e-mail and all transactions are subject to
TOP-TOY's standard terms and conditions:
http://www2.top-toy.com/Start?SuccTPL=legal_notice
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@...
http://mail.gnome.org/mailman/listinfo/xml
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@...
http://mail.gnome.org/mailman/listinfo/xml

Re: Avoiding emediate close of elements

by Martin Olsen-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?

--
Yours sincerely,
 TOP-TOY A/S
 Martin Olsen, IT-Systemdeveloper
 Telephone   +45 4616 3710
 Facsimile   +45 4616 3681
All information in this e-mail and all transactions are subject to
TOP-TOY's standard terms and conditions:
http://www2.top-toy.com/Start?SuccTPL=legal_notice
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@...
http://mail.gnome.org/mailman/listinfo/xml

Re: Avoiding emediate close of elements

by Darko Miletic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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>



_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@...
http://mail.gnome.org/mailman/listinfo/xml

Re: Avoiding emediate close of elements

by Daniel Veillard :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml@...
http://mail.gnome.org/mailman/listinfo/xml