例如:String xml = "<RESULT>" +
"<YHDAS>" +
"<YHDA>" +
"<YHBH>用户编号</YHBH>" +
"<YHMC>用户姓名</YHMC>" +
"<YHDZ>用户地址</YHDZ>" +
"<LXR>联系人</LXR>" +
"</YHDA>" +
"</YHDAS>" +
"</RESULT>"
求:如何利用JDOM获取到节点的值?
------解决方案--------------------------------------------------------
- Java code
String xml = "";StringReader read = new StringReader(xml); InputSource source = new InputSource(read); SAXBuilder sb = new SAXBuilder(); Document doc = sb.build(source); Element root = doc.getRootElement(); System.out.println(root.getName());// 输出根元素的名称(测试)