import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
public class DomparserTest4 {
public static void main(String[] args) {
DOMParser parser = new DOMParser();
try {
parser.parse("aaa.xml");
Document doc = parser.getDocument();
Element root = doc.getDocumentElement();
Element stu = (Element)root.getChildNodes().item(1);
NodeList ns = stu.getElementsByTagName("code");
Element code = (Element)ns.item(0);
//CDATA节点的解析
CDATASection cdata = (CDATASection)code.getChildNodes().item(0);
System.out.println(cdata.getTextContent());
} catch (Exception e) {
e.printStackTrace();
}
}
}