Here you can find the source of printAttribute(XMLStreamReader xmlr, int index, StringBuffer result)
private static void printAttribute(XMLStreamReader xmlr, int index, StringBuffer result)
//package com.java2s; /*/*w ww . j ava 2 s .com*/ * Copyright LGPL3 * YES Technology Association * http://yestech.org * * http://www.opensource.org/licenses/lgpl-3.0.html */ import javax.xml.stream.XMLStreamReader; public class Main { private static void printAttribute(XMLStreamReader xmlr, int index, StringBuffer result) { String prefix = xmlr.getAttributePrefix(index); String namespace = xmlr.getAttributeNamespace(index); String localName = xmlr.getAttributeLocalName(index); String value = xmlr.getAttributeValue(index); result.append(" "); printName(prefix, namespace, localName, result); result.append("='").append(value).append("'"); } private static void printName(XMLStreamReader xmlr, StringBuffer result) { if (xmlr.hasName()) { String prefix = xmlr.getPrefix(); String uri = xmlr.getNamespaceURI(); String localName = xmlr.getLocalName(); printName(prefix, uri, localName, result); } } private static void printName(String prefix, String uri, String localName, StringBuffer result) { if (uri != null && !("".equals(uri))) result.append("['").append(uri).append("']:"); if (prefix != null) result.append(prefix).append(":"); if (localName != null) result.append(localName); } }