Here you can find the source of printNamespaces(XMLStreamReader xmlr)
protected static void printNamespaces(XMLStreamReader xmlr)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 UNIT Information Technologies R&D Ltd * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w. j a v a 2s . c o m * Ferhat Erata - initial API and implementation * H. Emre Kirmizi - initial API and implementation * Serhat Celik - initial API and implementation * U. Anil Ozturk - initial API and implementation *******************************************************************************/ import javax.xml.stream.XMLStreamReader; public class Main { protected static void printNamespaces(XMLStreamReader xmlr) { for (int i = 0; i < xmlr.getNamespaceCount(); i++) { printNamespace(xmlr, i); } } protected static void printNamespace(XMLStreamReader xmlr, int index) { String prefix = xmlr.getNamespacePrefix(index); String uri = xmlr.getNamespaceURI(index); System.out.print(" "); if (prefix == null) System.out.print("xmlns='" + uri + "'"); else System.out.print("xmlns:" + prefix + "='" + uri + "'"); } }