Java XML Element Get findElementOrContainer(Document document, Element parent, String element)

Here you can find the source of findElementOrContainer(Document document, Element parent, String element)

Description

find Element Or Container

License

Apache License

Declaration

public static Element findElementOrContainer(Document document, Element parent, String element) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    public static Element findElementOrContainer(Document document, Element parent, String element) {
        NodeList nl = parent.getElementsByTagName(element);
        if (nl.getLength() == 0) {
            return null;
        }/*w  ww.  ja v a2 s . c o m*/
        return (Element) nl.item(0);
    }
}

Related

  1. findElement(Document doc, String tagName, Properties props)
  2. findElement(String name, Document doc)
  3. findElementAndSetElseCreateAndSet(Document document, Element parent, String child, boolean value)
  4. findElementElseCreateAndSet(Document document, Element parent, String child, boolean value)
  5. findElementList(String name, String attrName, String attrValue, Document doc)
  6. getElement(Document doc, QName elementQName)
  7. getElement(Document doc, String path)
  8. getElement(Document pDocument, String psTagName, int index)
  9. getElement(Element config, String elementName)