Example usage for org.w3c.dom Text deleteData

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

Introduction

In this page you can find the example usage for org.w3c.dom Text deleteData.

Prototype

public void deleteData(int offset, int count) throws DOMException;

Source Link

Document

Remove a range of 16-bit units 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);

    //String bridge = directions.substringData(offset,count);
    String bridge = directions.substringData(2, 3);
    name.appendData(bridge);/* ww  w .  j  a v a2s.  c o m*/
}

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

        //String bridge = directions.substringData(offset,count);
        String bridge = directions.substringData(2, 3);
        name.appendData(bridge);//from   ww  w  .jav  a2 s.c  o  m
    }