title: Processing CDATA from XML via DOM parser
body: <p>I've never processed XMLs before, so I'm not sure how to process CDATA in within an XML file. I'm getting lost in nodes, parents, child nodes, nList, etc.</p>
  
  <p>Can anyone tell me what my problem is from these snippets of code? </p>
  
  <p>My <code>getTagValue()</code> method works on all tags except "Details", which is the one that contains CDATA.</p>
  
  <pre><code>.....
  NodeList nList = doc.getElementsByTagName("Assignment");
  for (int temp = 0; temp &lt; nList.getLength(); temp++) {
      Node nNode = nList.item(temp);
      if (nNode.getNodeType() == Node.ELEMENT_NODE) {
          Element eElement = (Element) nNode;
          results = ("Class : " + getTagValue("ClassName", eElement)) + 
                    ("Period : " + getTagValue("Period", eElement)) +
                    ("Assignment : " + getTagValue("Details", eElement));
          myAssignments.add(results);
      }
  }
  .....
  private String getTagValue(String sTag, Element eElement) {
      NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
  
      Node nValue = (Node) nlList.item(0);
      if((CharacterData)nValue instanceof CharacterData)
      {
          return ((CharacterData) nValue).getData();
      }
      return nValue.getNodeValue();
  }
  </code></pre>