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

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

Introduction

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

Prototype

public void detach() throws DOMException;

Source Link

Document

Called to indicate that the Range is no longer in use and that the implementation may relinquish any resources associated with this Range.

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();/*from  w ww .j av  a  2s .co m*/
    range.detach();

}