Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force XMLSerializer not to collapse empty tags?

Is it possible via any configuration option to tell JavaScript's XMLSerializer not to collapse empty tags into self-closing tags? I'm feeding an xml string into the xml parser then reserializing it after making modifications to the tree, but where I have an explicit closing tag in the input, this is collapsed to a self-closing tag in the output which is causing problems.

like image 964
devios1 Avatar asked Nov 13 '22 16:11

devios1


1 Answers

If you don't have jquery available and only wanted to go via xmlserialzer way, you can also use npm package 'xmldom'.

var serializer = require('xmldom').XMLSerializer;
var str = serializer.serializeToString('your node');

It takes care of self closing tags(eg. script tags). NPM xmldom Works fine in IE11.

like image 76
gusaindpk Avatar answered Nov 15 '22 05:11

gusaindpk