日期:2014-05-20  浏览次数:21021 次

java 解析 xml <![CDATA[]]> 节点问题.....
<?xml version="1.0" encoding="utf-8"?> 
<response success="aa"> 
  bb </response> 

代吗为 
Java code
Document doc;
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setNamespaceAware(true);
  DocumentBuilder db = dbf.newDocumentBuilder();
  doc = db.parse(in);
  //NodeList n1 = doc.getElementsByTagName("messages");
  System.out.println(doc.getElementsByTagName("response").item(0).getAttributes().item(0).getNodeValue());
  System.out.println(doc.getElementsByTagName("response").item(0).getFirstChild().getNodeValue());



这样可以获得aa跟bb 
但是xml换成 
<?xml version="1.0" encoding="utf-8"?> 
<response success="aa"> 
  <![CDATA[bb]]> 
</response> 
加上 <![]]bb就出不来了。。 
请问是怎么回事....

------解决方案--------------------
http://topic.csdn.net/u/20090213/14/fb8d1077-63db-4cf3-93d0-c97089b4606a.html