Handles the xpath name, by creating the given node and its children.<p>

@param parent the parent node to use
@param xpathName the xpathName, ie <code>a[@b='c'][d='e'][text()='f']</code>

@return the new created element
15072
private static Element handleNode(Element parent, String xpathName) {

        // if node is no attribute, create a new node
        String childrenPart = null;
        String nodeName;
        int pos = xpathName.indexOf("[");
        if (pos > 0) {
            childrenPart = xpathName.substring(pos + 1, xpathName.length() - 1);
            nodeName = xpathName.substring(0, pos);
        } else {
            nodeName = xpathName;
        }
        // create node
        Element elem = parent.addElement(nodeName);
        if (childrenPart != null) {
            pos = childrenPart.indexOf("[");
            if ((pos > 0) && (childrenPart.indexOf("]") > pos)) {
                handleNode(elem, childrenPart);
                return elem;
            }
            if (childrenPart.contains("=")) {
                Map<String, String> children = CmsStringUtil.splitAsMap(childrenPart, "][", "=");
                // handle child nodes
                for (Map.Entry<String, String> child : children.entrySet()) {
                    String childName = child.getKey();
                    String childValue = child.getValue();
                    if (childValue.startsWith("'")) {
                        childValue = childValue.substring(1);
                    }
                    if (childValue.endsWith("'")) {
                        childValue = childValue.substring(0, childValue.length() - 1);
                    }
                    if (childName.startsWith("@")) {
                        elem.addAttribute(childName.substring(1), childValue);
                    } else if (childName.equals("text()")) {
                        elem.setText(childValue);
                    } else if (!childName.contains("(")) {
                        Element childElem = elem.addElement(childName);
                        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(childValue)) {
                            childElem.addText(childValue);
                        }
                    }
                }
            }
        }
        return elem;
    }
131783
public static Node selectNode(Node dom, String xpath) {
        return selector.selectNode(dom, xpath);
    }
295932
public static boolean hasChildNode(Node parentNode, String nodeName){
                return getChildNode(parentNode, nodeName, null) != null ? true : false;
        }
1054755
public Xml createChild(String child)
    {
        Check.notNull(child);

        final Element element = document.createElement(child);
        root.appendChild(element);
        return new Xml(document, element);
    }
937366
public boolean nextInnerElement(ElementContext parent, String childName) throws XMLException, IOException {
		while (nextInnerElement(parent)) {
			if (event.text.equals(childName))
				return true;
		}
		return false;
	}
131159
protected Element getElement(Object parent, String name) {
		if (name == null) {
			return null;
		}
		String id;
		if (parent == null) {
			id = getRootElement().getId();
		} else {
			id = groupToId.get(parent);
		}
		return Dom.getElementById(Dom.assembleId(id, name));
	}
927760
public void generateXml(Element parent, I_CmsConfigurationParameterHandler config) {

        if (config != null) {
            Element elem = parent.addElement(m_name);
            for (String attrName : m_attrs) {
                String value = config.getConfiguration().get(attrName);
                if (value != null) {
                    elem.addAttribute(attrName, value);
                }
            }
        }
    }
423222
private static List<Node> getChildren(Node parentNode, String name, String value){
                List<Node> childNodes = new ArrayList<Node>();
                if(parentNode == null || name == null){
                        return childNodes;
                }

                if (parentNode.getNodeType() == Node.ELEMENT_NODE && parentNode.hasChildNodes()) {
                        NodeList children = parentNode.getChildNodes();
                        for(int i=0; i < children.getLength(); i++){
                                Node child = children.item(i);
                                if(child != null && name.equals(child.getNodeName()) && (value == null || value.equals(child.getTextContent()))){
                                        childNodes.add(child);
                                }
                        }
                }

                return childNodes;
        }
547871
protected void initBodyElementName(String elementName) {

        if ((elementName == null)
            || (m_page.hasValue(elementName, getElementLocale())
                && !m_page.isEnabled(elementName, getElementLocale()))) {
            // elementName not specified or given element is disabled, determine default element
            List<String> allElements = m_page.getNames(getElementLocale());
            int elementCount = allElements.size();
            List<String> elements = new ArrayList<String>(elementCount);
            for (int i = 0; i < elementCount; i++) {
                // filter disabled elements
                if (m_page.isEnabled(allElements.get(i), getElementLocale())) {
                    elements.add(allElements.get(i));
                }
            }

            // get the active page elements
            List<CmsDialogElement> elementList = getElementList();
            for (int i = 0; i < elementList.size(); i++) {
                CmsDialogElement checkElement = elementList.get(i);
                if (elements.contains(checkElement.getName())) {
                    // get the first active element from the element list
                    setParamElementname(checkElement.getName());
                    return;
                }
            }

            // no matching active element found
            if (elements.contains(CmsDefaultPageEditor.XML_BODY_ELEMENT)) {
                // default legacy element present, use it
                setParamElementname(CmsDefaultPageEditor.XML_BODY_ELEMENT);
            } else {
                // use the first element from the element list
                setParamElementname(elements.get(0));
            }
        } else {
            // elementName specified and element is enabled or not present, set to elementName
            setParamElementname(elementName);
        }
    }
177728
function(event, tagName) {
    var element = Event.element(event);
    while (element.parentNode && (!element.tagName ||
        (element.tagName.toUpperCase() != tagName.toUpperCase())))
      element = element.parentNode;
    return element;
  }
929828
public XMLElementList getChildrenByName(String name) {
		XMLElementList selected = new XMLElementList();
		XMLElementList children = getChildren();
		
		for (int i=0;i<children.size();i++) {
			if (children.get(i).getName().equals(name)) {
				selected.add(children.get(i));
			}
		}
		
		return selected;
	}
741042
static public Element selectParentElement(Element element, String parentName) {
		Element parentElement = (Element) element.getParentNode();
		if (parentElement == null) {
			return null;
		}
		if (parentElement.getTagName().equals(parentName)) {
			return parentElement;
		}
		return selectParentElement(parentElement, parentName);
	}
28433
public static Element createElement(QName qname)
   {
      return createElement(qname.getLocalPart(), qname.getPrefix(), qname.getNamespaceURI());
   }
79843
public void endElement(String namespaceURI, String localName,
                           String qName) throws SAXException {
        trace("endElement:" + localName + "~" + qName);
        if (currentElement==null) {
            warn(qName + ": endElement before any startElement");
            return;
        }

        Node parentNode;
        boolean atDocumentRoot = false, foundTagToEnd = false;
        Element startElement = currentElement;

        while (!(foundTagToEnd || atDocumentRoot)) {
            parentNode = currentElement.getParentNode();

            if (parentNode.getNodeType()==Node.ELEMENT_NODE) {
                foundTagToEnd = isElementMatching(currentElement, qName);
                currentElement = (Element) parentNode;
            } else if (parentNode.getNodeType()==Node.DOCUMENT_NODE) {
                atDocumentRoot = true;
                if (startElement==currentDocument.getDocumentElement()) {
                    foundTagToEnd = isElementMatching(startElement, qName);
                } else {
                    currentElement = startElement;
                }
            } else {
                throw new IllegalArgumentException("Closing element " + qName
                                                   + ": expecting a parent ELEMENT_NODE but found " + parentNode);
            }
        }
        if (!foundTagToEnd) {
            warn(qName + ": endElement does not match startElement!");
        }
    }
1028854
@SuppressWarnings("unchecked")
    public <T extends XPathBuilder> T setName(final String name) {
        this.name = name;
        return (T) this;
    }
320557
public static NodeImpl createMethodNode(final String name, final NodeImpl parent,
      final Class<?>[] parameterTypes) {
    return new NodeImpl( //
        name, //
        parent, //
        false, //
        null, //
        null, //
        ElementKind.METHOD, //
        parameterTypes, //
        null, //
        null, //
        null, //
        null //
    );
  }
784697
@Override
    public Xml child(String name) {
        List<Xml> children = children(name);
        if (children.size() != 1) {
            logger.debug("Could not find individual child node: " + name);
            return new XmlAbsent(name);
        }
        return children.get(0);
    }