Example usage for org.w3c.dom.ranges Range deleteContents

List of usage examples for org.w3c.dom.ranges Range deleteContents

Introduction

In this page you can find the example usage for org.w3c.dom.ranges Range deleteContents.

Prototype

public void deleteContents() throws DOMException;

Source Link

Document

Removes the contents of a Range from the containing document or document fragment without returning a reference to the removed content.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder loader = factory.newDocumentBuilder();
    Document document = loader.parse("sample.xml");

    Element order = document.getDocumentElement();

    DocumentRange ranges = (DocumentRange) document;

    Range range = ranges.createRange();
    range.setStartBefore(order.getFirstChild());
    range.setEndAfter(order.getLastChild());

    range.deleteContents();
    range.detach();/*from w ww . j a  va 2 s  . c om*/

}