Java tutorial
//package com.java2s; //License from project: Open Source License import javax.xml.stream.XMLStreamReader; public class Main { private static void printName(String prefix, String uri, String localName, StringBuffer b) { if (uri != null && !("".equals(uri))) b.append("['" + uri + "']:"); if (prefix != null && !("".equals(prefix))) b.append(prefix + ":"); if (localName != null) b.append(localName); } private static void printName(XMLStreamReader xmlr, StringBuffer b) { if (xmlr.hasName()) { String prefix = xmlr.getPrefix(); String uri = xmlr.getNamespaceURI(); String localName = xmlr.getLocalName(); printName(prefix, uri, localName, b); } } }