Tag Archives: xmlbeans

XmlBeans: removing namespace attributes from the generated xml


public static void removeNamespaces(XmlObject root)
{
 String s;
 XmlCursor cursor = root.newCursor();
 cursor.toNextToken();
 while (cursor.hasNextToken())
 {
 if (cursor.isNamespace())
 {
 cursor.removeXml();
 }
 else
 {
 if (cursor.isStart() || cursor.isAttr())
 {
 s = cursor.getName().getLocalPart();
 cursor.setName(new QName(s));
 }
 cursor.toNextToken();
 }
 }
 cursor.dispose();
}

 

Advertisements
Tagged ,