List of usage examples for org.w3c.dom Document createCDATASection
public CDATASection createCDATASection(String data) throws DOMException;
CDATASection
node whose value is the specified string. From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; cdata.appendData("from java2s.com"); System.out.println(cdataNode.getLength()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; cdata.setData("from java2s.com"); System.out.println(cdataNode.substringData(2, 4)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; cdata.setData("from java2s.com"); System.out.println(cdataNode); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; cdata.appendData("from java2s.com"); cdata.deleteData(1, 2);/*ww w . j a v a 2 s .c o m*/ System.out.println(cdataNode); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; cdata.appendData("from java2s.com"); cdata.deleteData(1, 2);//from w w w .j ava 2 s .com System.out.println(cdataNode.getData()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; cdata.appendData("from java2s.com"); System.out.println(cdataNode); cdata.replaceData(1, 2, "new"); System.out.println(cdataNode); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xmlRecords)); Document doc = factory.newDocumentBuilder().parse(is); CDATASection cdataNode = doc.createCDATASection(""); CharacterData cdata = cdataNode; int offset = 0; cdata.insertData(offset, "a "); cdata.appendData(" b"); System.out.println(cdataNode); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true);//w w w . j ava 2 s.com factory.setExpandEntityReferences(false); Document doc = factory.newDocumentBuilder().parse(new File("filename")); Element element = doc.getElementById("key1"); CDATASection cdataNode = doc.createCDATASection(""); Comment commentNode = doc.createComment(""); Text textNode = doc.createTextNode(""); CharacterData cdata = cdataNode; cdata = commentNode; cdata = textNode; cdata.setData("some data"); int len = cdata.getLength(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true);/* www . j a v a2s . c o m*/ factory.setExpandEntityReferences(false); Document doc = factory.newDocumentBuilder().parse(new File("filename")); Element element = doc.getElementById("key1"); CDATASection cdataNode = doc.createCDATASection(""); Comment commentNode = doc.createComment(""); Text textNode = doc.createTextNode(""); // All three types of nodes implement the CharacterData interface CharacterData cdata = cdataNode; cdata = commentNode; cdata = textNode; // Delete text int offset = 0; int len = 5; cdata.deleteData(offset, len); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true);//w ww . j av a 2 s . c om factory.setExpandEntityReferences(false); Document doc = factory.newDocumentBuilder().parse(new File("filename")); Element element = doc.getElementById("key1"); CDATASection cdataNode = doc.createCDATASection(""); Comment commentNode = doc.createComment(""); Text textNode = doc.createTextNode(""); // All three types of nodes implement the CharacterData interface CharacterData cdata = cdataNode; cdata = commentNode; cdata = textNode; cdata.setData("some data"); int len = cdata.getLength(); int offset = 5; len = 4; String s = cdata.substringData(offset, len); }