java读取xml中标签属性

来源:百度知道 编辑:UC知道 时间:2024/06/22 00:30:16
如:<?xml version="1.0" encoding="GB2312"?>
<people>
<name>
<firstName value="aaaa">ge</firstName>
<secondName>baoliang</secondName>
</name>
<age>24</age>
</people>
我想得到firstname中的value 怎么用java实现啊。
Element root=document.getDocumentElement(); 就用这个root继续吧。谢谢啦

给你个地址,是我用dom4j写的读写xml的例子。看看吧!

http://hi.baidu.com/xc_jetguo/blog/item/575c203000761a1eebc4afa8.html

对dom4j