List of utility methods to do XML Child Get by Namespace
List | getChildElementsByTagNameNS(Element parent, String namespaceURI, String localName) get Child Elements By Tag Name NS List<Element> elems = new ArrayList<Element>(); NodeList nodes = parent.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE && node.getNamespaceURI().equals(namespaceURI) && node.getLocalName().equals(localName)) { elems.add((Element) node); return elems; |
Element[] | getChildElementsByTagNameNS(Element parentElement, String namespaceURI, String localName) Retrieves all immediate child elements of the specified element whose names match the provided name parameter.
List children = new ArrayList(); NodeList nodes = parentElement.getChildNodes(); int length = nodes.getLength(); for (int index = 0; index < length; ++index) { if (nodes.item(index).getNodeType() == Node.ELEMENT_NODE && namespaceURI.equals(nodes.item(index).getNamespaceURI()) && localName.equals(nodes.item(index).getNodeName())) { children.add(nodes.item(index)); ... |
void | getChildElementsByTagNameNS(Vector vector, Node node, String tagName, String namespace) get Child Elements By Tag Name NS NodeList list = node.getChildNodes(); for (int i = 0; list != null && i < list.getLength(); i++) { try { Element element = (Element) list.item(i); if (tagName.equals(getElementLocalName(element)) && namespace.equals(getElementNamespaceURI(element))) { vector.addElement(element); } else { ... |
String | getChildElementValueNS(Element parentElm, String elementNamespaceURI, String elementLocalName) get Child Element Value NS String elementValue = null; NodeList elemList = parentElm.getElementsByTagNameNS(elementNamespaceURI, elementLocalName); if (elemList != null && elemList.getLength() > 0) { Element elm = (Element) elemList.item(0); NodeList childNodes = elm.getChildNodes(); StringBuffer value = new StringBuffer(); for (int elemCount = 0; elemCount < childNodes.getLength(); elemCount++) { if (childNodes.item(elemCount) instanceof org.w3c.dom.Text) { ... |