Get the value of an element. We expect 1 child node otherwise we raise an
exception.

@param el          Node whose value we want
@param name        String name to make exception messages more readable
@return String     node value
@throws SAXException
508194
public static String getReqOneNodeVal(final Node el, final String name)
      throws SAXException {
    String str = getOneNodeVal(el, name);

    if ((str == null) || (str.length() == 0)) {
      throw new SAXException("Missing property value: " + name);
    }

    return str;
  }
953714
public Node getNamedItem(String name)
  {

    for (int n = dtm.getFirstAttribute(element); n != DTM.NULL;
            n = dtm.getNextAttribute(n))
    {
      if (dtm.getNodeName(n).equals(name))
        return dtm.getNode(n);
    }

    return null;
  }
823841
public static Element dataElement(Element context, String name) {
        return context != null ? context.querySelector("[data-element=" + name + "]") : null;
    }
868514
private String getNextElementsValue(String wantedName) throws IOException {
    boolean gotSTART_ELEMENT = false;
    try {
      int eventType = in.getEventType();
      while(true) {
        switch(eventType) {
          case XMLStreamConstants.CHARACTERS: // 4
            if(gotSTART_ELEMENT) {
              // XML returns "\n" instead of empty (zero-length) string
              // for elements like <x></x>
              return in.getText().trim();
            }
            break;
          case XMLStreamConstants.END_DOCUMENT: // 8
            throw new IOException("End of XML while looking for element [" +
              wantedName + "]");
            // break;
          case XMLStreamConstants.START_ELEMENT : // 1
            if(gotSTART_ELEMENT) {
              throw new IOException("START_ELEMENT [" +
                in.getName() +
                " event when expecting CHARACTERS event for [" +
                wantedName + "]");
            } else if(in.getName().toString().equals(wantedName)) {
              gotSTART_ELEMENT = true;
            } else {
              throw new IOException("unexpected element name [" +
                in.getName() + "], was expecting [" +
                wantedName + "]");
            }
            break;
          case XMLStreamConstants.COMMENT:
          case XMLStreamConstants.END_ELEMENT: // 2
          case XMLStreamConstants.SPACE:
          case XMLStreamConstants.START_DOCUMENT: // 7
            // these are in XML but we don't need them
            break;
          // these should never appear in edits XML
          case XMLStreamConstants.ATTRIBUTE:
          case XMLStreamConstants.CDATA:
          case XMLStreamConstants.DTD:
          case XMLStreamConstants.ENTITY_DECLARATION:
          case XMLStreamConstants.ENTITY_REFERENCE:
          case XMLStreamConstants.NAMESPACE:
          case XMLStreamConstants.NOTATION_DECLARATION:
          case XMLStreamConstants.PROCESSING_INSTRUCTION:
          default:
            throw new IOException("Unsupported event type [" +
              eventType + "] (see XMLStreamConstants)");
        }
        if(!in.hasNext()) { break; }
        eventType = in.next();
      }
    } catch(XMLStreamException e) {
      throw new IOException("Error reading XML stream", e);
    }
    throw new IOException(
      "Error reading XML stream, should never reach this line, " +
      "most likely XML does not have elements we are loking for");
  }
893403
@SuppressWarnings("unused")
		private String getTextValue(Element ele, String tagName) {
			String textVal = null;
			NodeList nl = ele.getElementsByTagName(tagName);
			if(nl != null && nl.getLength() > 0) {
				Element el = (Element)nl.item(0);
				textVal = el.getFirstChild().getNodeValue();
			}

			return textVal;
		}
488526
public int intValue(String name, String namespace) {
        String s = childValue(name, namespace);
        if (s != null) {
            return Integer.parseInt(s);
        }
        throw new IllegalArgumentException(this + ": content: " + name);
    }
822735
static String getChildElementText(Element parent, String name) {
        // Get children
        List list = DomUtils.getChildElementsByName(parent, name);

        if (list.size() == 1) {
            Element child = (Element) list.get(0);

            StringBuffer buf = new StringBuffer();

            NodeList children = child.getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                Node node = children.item(i);
                if (node.getNodeType() == Node.TEXT_NODE ||
                        node.getNodeType() == Node.CDATA_SECTION_NODE) {
                    Text text = (Text) node;
                    buf.append(text.getData().trim());
                }
            }

            return buf.toString();
        } else {
            return null;
        }
    }
138508
@Override
    public String getValue(String xmlName) {
        int index = getIndex(xmlName);

        if (index < 0) {
            return null;
        }
        return getValue(index);
    }
498631
public Xml getChild(String name)
    {
        Check.notNull(name);

        final NodeList list = root.getChildNodes();
        for (int i = 0; i < list.getLength(); i++)
        {
            final Node node = list.item(i);
            if (node instanceof Element && node.getNodeName().equals(name))
            {
                return new Xml(document, (Element) node);
            }
        }
        throw new LionEngineException(ERROR_NODE + name);
    }
955890
public function getByName($name, $throwException = true)
    {
        foreach ($this as $element) {

            if (!$element instanceof Element\NamedElement) {
                throw new Exception\CollectionException();
            }

            if ($element->getName() === $name) {
                return $element;
            }
        }

        if ($throwException) {
            throw new Exception\NotFoundException();
        }

        return null;
    }
32781
public static boolean hasChildren(final Element el) throws SAXException {
    NodeList children = el.getChildNodes();

    for (int i = 0; i < children.getLength(); i++) {
      Node curnode = children.item(i);

      short ntype =  curnode.getNodeType();
      if ((ntype != Node.TEXT_NODE) &&
          (ntype != Node.CDATA_SECTION_NODE) &&
          (ntype != Node.COMMENT_NODE)) {
        return true;
      }
    }

    return false;
  }
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;
	}
494729
public SOAPElement getElement(SOAPElement element, String strElementName)
    {
        Iterator<?> iterator = element.getChildElements();
        while (iterator.hasNext())
        {
            javax.xml.soap.Node elMessageType = (javax.xml.soap.Node)iterator.next();
            if (elMessageType instanceof SOAPElement)
            {
                if (strElementName == null)
                    return (SOAPElement)elMessageType;    // The message type
                if (strElementName.equalsIgnoreCase(((SOAPElement)elMessageType).getElementName().getLocalName()))
                    return (SOAPElement)elMessageType;    // The message type
            }
        }
        return null;    // not found
    }
735086
public static Element getChild(Element parent, String childName) {
		NodeList nodes = parent.getChildNodes();
		for (int i = 0; i < nodes.getLength(); ++i) {
			Node node = nodes.item(i);
			if ((node instanceof Element) && node.getNodeName().equals(childName))
				return (Element)node;
		}
		return null;
	}
771612
public NodeConfig getChildNodeByName(String name) {
		if (name == null) {
			throw new NullPointerException("Node name is null");
		}
		if (childrenNodes != null && childrenNodes.size() > 0) {
			for (NodeConfig childNode : childrenNodes) {
				if (childNode.getName().equals(name)) {
					return childNode;
				}
			}
		}
		return null;
	}
104182
public void entityReference(String name) throws org.xml.sax.SAXException
    {
        if (m_elemContext.m_startTagOpen)
        {
            closeStartTag();
            m_elemContext.m_startTagOpen = false;
        }

        try
        {
            if (shouldIndent())
                indent();

            final java.io.Writer writer = m_writer;
            writer.write('&');
            writer.write(name);
            writer.write(';');
        }
        catch(IOException e)
        {
            throw new SAXException(e);
        }
        
        if (m_tracer != null)
            super.fireEntityReference(name);            
    }
745693
public final void entityReference(String name)
        throws org.xml.sax.SAXException
    {
        try
        {

        final java.io.Writer writer = m_writer;
        writer.write('&');
        writer.write(name);
        writer.write(';');
        
        } catch(IOException e)
        {
            throw new SAXException(e);
        }
    }