title: return child element by name XML
body: <p>I'm a complete beginner at working with XML, so please bear with me...I'm trying to write a simple method to return the first child element by it's specified name.</p>
  
  <p>The method I have is:</p>
  
  <pre><code>public Element getChild(Element parent, String childName) {
  
      NodeList list = parent.getElementsByTagName(*);
  
      for(int i = 0; i &lt; list.getLength(); i++) {
          if (list.item(i).getNodeName().equals(childName)) {
              return (Element)list.item(i);
          }
      }
      return null;        
  }
  </code></pre>
  
  <p>But, the line <code>NodeList list = parent.getElementsByTagName(*);</code> gives me a generic "illegal start of expression" error. Can somebody explain what I'm doing wrong? I've been googling for twenty minutes with no luck, which means it's either really obscure or really obvious.</p>