List of utility methods to do XML Node to String
String | toWellKnowName(Node vertexStyleNode) to Well Know Name if (vertexStyleNode == null) { return ""; String value = "square"; try { NamedNodeMap atts = vertexStyleNode.getAttributes(); String nodeVal = atts.getNamedItem("class").getNodeValue(); if (nodeVal.indexOf("Square") > -1) { ... |
void | toWriter(Node node, Writer writer, Map Writes an XML node to a writer. try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); for (Map.Entry<String, String> property : outputProperties.entrySet()) { try { transformer.setOutputProperty(property.getKey(), property.getValue()); } catch (IllegalArgumentException e) { DOMSource source = new DOMSource(node); StreamResult result = new StreamResult(writer); transformer.transform(source, result); } catch (TransformerConfigurationException e) { } catch (TransformerFactoryConfigurationError e) { |
String | toXML(Node node) Xml to string. try { Source source = new DOMSource(node); StringWriter stringWriter = new StringWriter(); Result result = new StreamResult(stringWriter); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); transformer.transform(source, result); return stringWriter.getBuffer().toString(); ... |
String | toXml(Node node) Returns String representation of the the XML node (document or element). Source source = new DOMSource(node); StringWriter writer = new StringWriter(); Result result = new StreamResult(writer); Transformer t = TransformerFactory.newInstance().newTransformer(); t.transform(source, result); return writer.toString(); |
String | toXml(Node node) to Xml Source src = new DOMSource(node); return toXml(src, -1); |
String | toXML(Node node) Takes a Node object and converts it to a String representing the valid XML structure. Transformer tf = TransformerFactory.newInstance().newTransformer(); tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); tf.setOutputProperty(OutputKeys.INDENT, "yes"); tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); Writer out = new StringWriter(); tf.transform(new DOMSource(node), new StreamResult(out)); return out.toString(); ... |
String | toXml(Node node, boolean keepHeader) to Xml Transformer transformer; DOMSource xmlSource = new DOMSource(node); transformer = TransformerFactory.newInstance().newTransformer(); StringWriter writer = new StringWriter(); StreamResult outputTarget = new StreamResult(writer); transformer.transform(xmlSource, outputTarget); String str = writer.getBuffer().toString(); if (!keepHeader) ... |
String | toXMLString(final Node value) to XML String return toXMLString(new DOMSource(value)); |
String | toXMLString(Node node) to XML String if (node == null) { return ""; try { Transformer tran = tf.newTransformer(); tran.setOutputProperty(OutputKeys.INDENT, "yes"); StringWriter swriter = new StringWriter(); Source src = new DOMSource(node); ... |
String | toXMLString(Node node) to XML String ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeToStream(baos, node); return new String(baos.toByteArray(), "UTF-8"); |