Here you can find the source of stripNamespaceDeclarations(String xml)
public static String stripNamespaceDeclarations(String xml)
//package com.java2s; /*/*from ww w . ja va 2s .c om*/ * Copyright (c) 2010-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.ArrayList; import java.util.List; public class Main { public static List<String> declarations = new ArrayList<>(); public static String stripNamespaceDeclarations(String xml) { if (xml == null) { return null; } for (String declaration : declarations) { for (;;) { int i = xml.indexOf(declaration); if (i < 0) { break; } int j = i + declaration.length(); while (j < xml.length() && Character.isWhitespace(xml.charAt(j))) { j++; } String before = xml.substring(0, i); String after = j < xml.length() ? xml.substring(j, xml.length()) : ""; xml = before + after; } } int i = xml.indexOf('>'); if (i > 0) { if (Character.isWhitespace(xml.charAt(i - 1))) { xml = xml.substring(0, i - 1) + xml.substring(i, xml.length()); } } return xml; } }