List of usage examples for org.w3c.dom Document createTextNode
public Text createTextNode(String data);
Text
node given the specified string. From source file:Main.java
/** * This method creates a new textnode with the passed on value. * * @param sValue The value for the new textnode. * @param nParent The parent node.// w ww . j a va2 s . com */ public static void createText(String sValue, Node nParent) { if (nParent != null) { Document dDoc = nParent.getOwnerDocument(); Node nTemp = dDoc.createTextNode(sValue); nParent.appendChild(nTemp); } }
From source file:Main.java
public static void writeStringValue(Document document, Element element, String elementValue) { Text textNode = document.createTextNode(elementValue); element.appendChild(textNode);/*from ww w . ja v a 2 s . co m*/ }
From source file:Main.java
public static void addText(Document doc, Node parent, String data) { parent.appendChild(doc.createTextNode(data)); }
From source file:Main.java
/** * Add a text node to a node.//w ww . j a v a2 s.c o m * * @param doc document * @param node parent node * @param text the text */ public static void addText(Document doc, Node node, String text) { node.appendChild(doc.createTextNode(text)); }
From source file:Main.java
/** * Add literal text to the supplied element. * @param element Target DOM Element./* ww w.ja v a2s. c o m*/ * @param literalText Literal text to be added. * @return if true all the operation are done. */ public static boolean addLiteral(Element element, String literalText) { try { Document document = element.getOwnerDocument(); Text literal = document.createTextNode(literalText); element.appendChild(literal); return true; } catch (Exception e) { return false; } }
From source file:Main.java
public static void addNode(Document file, String text, String nodeName) { file.getDocumentElement().appendChild(file.createTextNode(" ")); addOneElement(file, text, nodeName); }
From source file:Main.java
private static Element createTextElement(String name, String value, Document document) { Element element = document.createElement(name); element.appendChild(document.createTextNode(value)); return element; }
From source file:Main.java
public static synchronized void appedIndent(Element e, int indent) { Document doc = e.getOwnerDocument(); if (indent == 0) { e.appendChild(doc.createTextNode("\n")); }//from w w w . ja v a2 s . c o m for (int i = 0; i < indent; i++) { if (i == 0) { e.appendChild(doc.createTextNode("\n\t")); } else { e.appendChild(doc.createTextNode("\t")); } } }
From source file:Main.java
public static synchronized void appendIndent(Element e, Node pos, int indent) { Document doc = e.getOwnerDocument(); if (indent == 0) { e.insertBefore(doc.createTextNode("\n"), pos); }//from w ww. j a va2 s . c om for (int i = 0; i < indent; i++) { if (i == 0) { e.insertBefore(doc.createTextNode("\n\t"), pos); } else { e.insertBefore(doc.createTextNode("\t"), pos); } } }
From source file:Main.java
public static Node duplicate(Node node, Document ownerDocument) { if (node instanceof Text) return ownerDocument.createTextNode(node.getNodeValue()); Node newNode = ownerDocument.createElement(node.getNodeName()); NamedNodeMap attribs = node.getAttributes(); for (int i = 0; i < attribs.getLength(); i++) { Node attrib = attribs.item(i); addAttribute(newNode, attrib.getNodeName(), attrib.getNodeValue()); }//from ww w .java2s . co m for (Node n = node.getFirstChild(); n != null; n = n.getNextSibling()) { Node newN = duplicate(n, ownerDocument); newNode.appendChild(newN); } return newNode; }