List of utility methods to do XML Element Root
int | getRootElementPosition(String buf, Element root) get Root Element Position NodeList children = root.getOwnerDocument().getChildNodes(); int pos = 0; for (int i = 0; i < children.getLength(); i++) { Node n = children.item(i); if (n != root) { String s = n.getNodeValue(); if (s != null) { pos += s.length(); ... |
Element | getRootFaceletElement(Document document) get Root Facelet Element Element root = document.getDocumentElement();
Element component = findComponentElement(root);
return component != null ? component : root;
|
Element | getRootFromPom(File pomFile) get Root From Pom DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(pomFile);
Element root = document.getDocumentElement();
return root;
|
Element | getRootFromString(String str) get Root From String return getAsDocument(str).getDocumentElement();
|
Node | getRootNode(Document doc, String nodeName) get Root Node NodeList nodes = doc.getElementsByTagName(nodeName); if (nodes == null || nodes.getLength() == 0) return (null); return (nodes.item(0)); |
Node | getRootNode(Document document) get Root Node NodeList nodeList = document.getChildNodes();
return nodeList.item(0);
|
Node | getRootNode(final String xmlContent) get Root Node final Document document = parse(xmlContent); return document.getDocumentElement(); |
String | getRootTagName(String xml) Returns root tagname DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder builder = dbf.newDocumentBuilder(); Document document = builder.parse(new InputSource(new StringReader(xml))); return document.getDocumentElement().getTagName(); |