preventing empty xml elements are converted to self closing elements



I am using Xerces Library for writing XML in document . For that I am using OutputFormat class passing the object of OutputFormat in XMLSerializer. But all of my empty xml elements are converted to self-closing xml elements.


I want this:



<Company Name="Dummy">
</Company>


But its coming like



<Company Name="Dummy" />


I have tried below code:



try
{
//print
OutputFormat format = new OutputFormat(dom,"iso-8859-1",true);

//to generate output to console use this serializer
XMLSerializer serializer = new XMLSerializer(System.out, format);


serializer.serialize(dom);

} catch(IOException ie) {
ie.printStackTrace();


}


Can someone help me out on this.


Thanks,


No comments:

Post a Comment