如题,现在可以读取xml文件,使用getElementsByTagName()读取的话会读取所有元素
xml文件结构为:<station id="LR1">
<operation>JobId</operation>
<operation>PostId</operation>
</station><station id="LR2">
<operation>accountName</operation>
</station>
如何根据station的id获取指定的值呢
比如我根据id "LR1" 去获取JobId,PostId这两个值?xml根据Id获取JavaWeb取值
xml文件结构为:<station id="LR1">
<operation>JobId</operation>
<operation>PostId</operation>
</station><station id="LR2">
<operation>accountName</operation>
</station>
如何根据station的id获取指定的值呢
比如我根据id "LR1" 去获取JobId,PostId这两个值?xml根据Id获取JavaWeb取值
可以看看dom4j,应该可以实现
应该是这样
doc.selectSingleNode这个方法貌似在Document对象里面没找到...
是用JAVA代码读取的.
Document doc = builder.parse(filePath+"huidui.xml");
doc.normalize();
NodeList links = doc.getElementsByTagName("station");
0.0 你们的document对象是引用的什么jar包的.
为毛我的没这方法都..我是引用的这个import org.w3c.dom.Document;