import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;public class TestCData {
public static void main(String[] args) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new FileInputStream("test.xml"));
Element e = doc.getDocumentElement();
NodeList nl = e.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node n = nl.item(i);
if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
System.out.println(n.getNodeValue());
}
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货