Example usage for org.w3c.dom Text substringData

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

Introduction

In this page you can find the example usage for org.w3c.dom Text 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 modifyingTextbyCuttingandPasting(Document doc) {
    Element root = doc.getDocumentElement();
    Element place = (Element) root.getFirstChild();
    Text name = (Text) place.getFirstChild().getFirstChild();
    Text directions = (Text) place.getLastChild().getFirstChild();

    //    name.deleteData(offset,count);
    name.deleteData(2, 3);/*from w  w w.jav a 2  s .c  o  m*/

    //String bridge = directions.substringData(offset,count);
    String bridge = directions.substringData(2, 3);
    name.appendData(bridge);
}

From source file:DOMEdit.java

public static void modifyingTextbyCuttingandPasting(Document doc) {
        Element root = doc.getDocumentElement();
        Element place = (Element) root.getFirstChild();
        Text name = (Text) place.getFirstChild().getFirstChild();
        Text directions = (Text) place.getLastChild().getFirstChild();

        //    name.deleteData(offset,count);
        name.deleteData(2, 3);/*from   www  . j  av a  2s .c  om*/

        //String bridge = directions.substringData(offset,count);
        String bridge = directions.substringData(2, 3);
        name.appendData(bridge);
    }