List of utility methods to do XML Element Get
Boolean | getElementAsBoolean(Element e, String name) get Element As Boolean return getElementAsBoolean(e, name, false);
|
Float | getElementAsFloat(Element e, String name, Float dft) get Element As Float String num = getElement(e, name); return num.equals("") ? dft : Float.parseFloat(num); |
int | getElementAsInt(Element element) get Element As Int return Integer.parseInt(element.getTextContent());
|
String | getElementAttributeValue(Document doc, String tagName, String attributeName) Return the named attribute from the specified element in the (XML) document. return getAttributeValue(doc.getElementsByTagName(tagName), attributeName);
|
boolean | getElementBooleanValue(Document document, Element parent, String element) get Element Boolean Value return Boolean.valueOf(getElementStringValue(document, parent, element)).booleanValue();
|
Element | getElementByClass(Element ele, String name) Get child element by classname List<Element> list = getElementsByClass(ele, name); if (list.size() > 0) return list.get(0); return null; |
List | getElementByFilter(Document doc, NodeFilter filter) get Element By Filter List<Element> result = new ArrayList<Element>(); DocumentTraversal traversable = (DocumentTraversal) doc; int whatToShow = NodeFilter.SHOW_ELEMENT; NodeIterator iterator = traversable.createNodeIterator(doc, whatToShow, filter, true); Node current = null; while ((current = iterator.nextNode()) != null) { result.add((Element) current); return result; |
Element | getElementByID(Element el, String id) get Element By ID if (el == null) return null; String thisId = el.getAttribute("id"); if (id.equals(thisId)) return el; NodeList list = el.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); ... |
Element | getElementByID(Element el, String id) DOCUMENTME if (el == null) { return null; String thisId = el.getAttribute("id"); if (id.equals(thisId)) { return el; NodeList list = el.getChildNodes(); ... |
Element | getElementById(Element element, String id) get Element By Id return getElementById(element.getChildNodes(), id);
|