How do I remove namespaces from xml in java?
Manohar Changed status to publish June 19, 2019
public static String removeXmlNamespaceAndPreamble(String xmlString) {
return xmlString.replaceAll("(<\\?[^<]*\\?>)?", "").
replaceAll("xmlns.*?(\"|\').*?(\"|\')", "")
.replaceAll("(</)(\\w+:)(.*?>)", "$1$3")
.replaceAll(":","");
.replaceAll("(<)(\\w+:)(.*?>)", "$1$3")
}
I hope the above snippet will work, please try.
Manohar Changed status to publish June 19, 2019
