Example usage for org.w3c.dom Document getDocumentElement

List of usage examples for org.w3c.dom Document getDocumentElement

Introduction

In this page you can find the example usage for org.w3c.dom Document getDocumentElement.

Prototype

public Element getDocumentElement();

Source Link

Document

This is a convenience attribute that allows direct access to the child node that is the document element of the document.

Usage

From source file:Main.java

public static final Element getRootElement(Document document) {
    return document.getDocumentElement();
}

From source file:Main.java

public static Element getRoot(Document xmlDoc) {
    return xmlDoc.getDocumentElement();
}

From source file:Main.java

public static Element getRootElement(Document document) {
    return document.getDocumentElement();
}

From source file:Main.java

public static void addCDATA(Document doc) {
    Element root = doc.getDocumentElement();
    Element place = (Element) root.getFirstChild();
    Element directions = (Element) place.getLastChild();
    String dirtext = "cdData.";
    CDATASection dirdata = doc.createCDATASection(dirtext);
    directions.replaceChild(dirdata, directions.getFirstChild());
}

From source file:Main.java

public static NodeList getChildNodes(Document document) {
    return document.getDocumentElement().getChildNodes();
}

From source file:Main.java

public static Node getRootNodeFromDocument(Document document) {
    return document.getDocumentElement();
}

From source file:Main.java

private static void makeChanges(Document document) {
    Element root = document.getDocumentElement();
    root.setAttribute("test", "testvalue");
}

From source file:Main.java

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

    name.setData("newName");
    directions.setData("newDirection");
}

From source file:Main.java

public static Element readRoot(Document document) {
    return document.getDocumentElement();
}

From source file:Main.java

private static String getXPath(Document document, String elementName) {
    return document.getDocumentElement().getNodeName() + getXPath(document.getDocumentElement(), elementName);
}