shabashj
11/2/2015 - 2:46 PM

change namespaces in XML

change namespaces in XML

var mNamespaces = {
  "sap.ui.unified":"unified",
	"sap.ui.core.mvc":"mvc",
	"sap.ui.core":"core",
	"sap.ui.layout.form":"f",
	"sap.ui.layout":"l"
};

_.forEach(mNamespaces, function(short, namespace) {
	var re = new RegExp(namespace, 'g');
	sXML = sXML.replace(re, short);
});

//OR

for (var name in mNamespaces){
	var re = new RegExp(name, 'g');
	sXML = sXML.replace(re, mNamespaces[name]);
}