How to convert <node/> to <node></node> with libxml (converting empty elements to start-end tag pairs)

While generating an XML content, I get an empty node <node/>, and I want it to be <node></node>. (Since <node></node> is the correct form of c14n, the progress called "converting empty elements to start-end tag pairs")

How should I convert it?

There's a way hinted by Jim Garrison(Thank you) to do this, by using xmlBufferCreate, xmlSaveToBuffer, xmlSaveDoc, xmlSaveClose with xmlSaveOption: XML_SAVE_NO_EMPTY

Answers


Take a look at the libxml2 documentation, specifically xmlSaveOption value XML_SAVE_NO_EMPTY


I found another way which is easier when the nodes are generated under control, by simply giving value "" to the node.


Need Your Help

How to write modular Ember.js apps

ember.js

Is there any guidance on how to write modular Ember.js apps? I have seen Tom Dale's position on AMD here so I am not going to force fit AMD on to the framework (as some have attempted here). It app...