Example usage for org.w3c.dom CDATASection substringData

List of usage examples for org.w3c.dom CDATASection substringData

Introduction

In this page you can find the example usage for org.w3c.dom CDATASection substringData.

Prototype

public String substringData(int offset, int count) throws DOMException;

Source Link

Document

Extracts a range of data from the node.

Usage

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));
}