Code example for XmlPullParserFactory

Methods: newSerializer

0
        } 
    } 
 
    private String nodeToNormalizedString(Node node)
            throws XmlPullParserException, IOException { 
        StringWriter writer = new StringWriter();
        XmlSerializer xmlSerializer = xmlPullParserFactory.newSerializer();
        xmlSerializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
        xmlSerializer.setOutput(writer);
        emitNode(xmlSerializer, node);
        xmlSerializer.flush();
        return writer.toString();
    } 
 
    private void emitNode(XmlSerializer serializer, Node node) throws IOException {
        if (node == null) {
            throw new UnsupportedOperationException("Cannot emit null nodes");
 
        } else if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) node;
            serializer.startTag(element.getNamespaceURI(), element.getLocalName());