List of usage examples for javax.xml.stream.events Attribute writeAsEncodedUnicode
public void writeAsEncodedUnicode(Writer writer) throws javax.xml.stream.XMLStreamException;
From source file:Main.java
private static void writeAsEncodedUnicode(StartElement element, Writer writer, boolean isEmpty) throws XMLStreamException { try {//from ww w . j a v a2 s .c o m // Write start tag. writer.write('<'); QName name = element.getName(); String prefix = name.getPrefix(); if (prefix != null && prefix.length() > 0) { writer.write(prefix); writer.write(':'); } writer.write(name.getLocalPart()); // Write namespace declarations. Iterator nsIter = element.getNamespaces(); while (nsIter.hasNext()) { Namespace ns = (Namespace) nsIter.next(); writer.write(' '); ns.writeAsEncodedUnicode(writer); } // Write attributes Iterator attrIter = element.getAttributes(); while (attrIter.hasNext()) { Attribute attr = (Attribute) attrIter.next(); writer.write(' '); attr.writeAsEncodedUnicode(writer); } if (isEmpty) writer.write('/'); writer.write('>'); } catch (IOException ioe) { throw new XMLStreamException(ioe); } }