List of utility methods to do XML Element Get
Element | findElement(Document doc, String elementNS, String elementName, String attrName, String attrValue) find Element return findElement(doc.getDocumentElement(), elementNS, elementName, attrName, attrValue);
|
Element | findElement(Document doc, String tagName, Properties props) Find an element Element elmt = null; NodeList nlist = doc.getElementsByTagName(tagName); for (int i = 0; i < nlist.getLength() && elmt == null; i++) { Node node = nlist.item(i); if (node instanceof Element) { Element temp = (Element) node; boolean matches = true; for (Enumeration en = props.keys(); en.hasMoreElements() && matches;) { ... |
Element | findElement(String name, Document doc) Finds the first (breadth first) DOM element with the specified name. return findElement(name, null, null, doc);
|
Element | findElementAndSetElseCreateAndSet(Document document, Element parent, String child, boolean value) find Element And Set Else Create And Set return findElementAndSetElseCreateAndSet(document, parent, child, "" + value); |
Element | findElementElseCreateAndSet(Document document, Element parent, String child, boolean value) find Element Else Create And Set return findElementElseCreateAndSet(document, parent, child, value + ""); |
Vector | findElementList(String name, String attrName, String attrValue, Document doc) Gets a list of DOM elements with the specified name that have an attribute with the given name and value. if (name == null) return null; Vector v = new Vector(); NodeList list = doc.getElementsByTagName(name); int size = list.getLength(); for (int i = 0; i < size; i++) { Node node = list.item(i); if (!(node instanceof Element)) ... |
Element | findElementOrContainer(Document document, Element parent, String element) find Element Or Container NodeList nl = parent.getElementsByTagName(element); if (nl.getLength() == 0) { return null; return (Element) nl.item(0); |
Element | getElement(Document doc, QName elementQName) Get an element from the document given its QName First an attempt to get the element based on its namespace is made, failing which an element with the localpart ignoring any namespace is returned. NodeList nl = doc.getElementsByTagNameNS(elementQName.getNamespaceURI(), elementQName.getLocalPart()); if (nl.getLength() == 0) { nl = doc.getElementsByTagNameNS("*", elementQName.getLocalPart()); if (nl.getLength() == 0) nl = doc.getElementsByTagName(elementQName.getPrefix() + ":" + elementQName.getLocalPart()); if (nl.getLength() == 0) return null; return (Element) nl.item(0); |
String | getElement(Document doc, String path) get Element return xpath.compile(path).evaluate(doc);
|
Element | getElement(Document pDocument, String psTagName, int index) returns a XML element. NodeList rows = pDocument.getDocumentElement().getElementsByTagName(psTagName);
return (Element) rows.item(index);
|