<Messages>
<Message>
<CONTENT>
<Map>
<Item>
<Key>MessageID</Key><Value>a0f630e0-aeec-11e2-b248-0000c0a8016e</Value>
</Item>
<Item><Key>ApplicationID</Key><Value>MH</Value></Item>
<Item><Key>CreatedTime</Key><Value>2013-04-27 :43:31.054</Value></Item>
<Item>
<Key>DATA</Key>
<Value>
<Item><Key>name</Key><Value>indexNum</Value></Item>
<Item><Key>jgdm</Key><Value>0105</Value></Item></Value>
</Item>
</Map>
</CONTENT>
<TAIL/>
</Message>
</Messages>
我想根据name获取值,也就是说根据name获取到indexNum的值,怎么获取啊,谢谢了 JavaXML节点值
<Message>
<CONTENT>
<Map>
<Item>
<Key>MessageID</Key><Value>a0f630e0-aeec-11e2-b248-0000c0a8016e</Value>
</Item>
<Item><Key>ApplicationID</Key><Value>MH</Value></Item>
<Item><Key>CreatedTime</Key><Value>2013-04-27 :43:31.054</Value></Item>
<Item>
<Key>DATA</Key>
<Value>
<Item><Key>name</Key><Value>indexNum</Value></Item>
<Item><Key>jgdm</Key><Value>0105</Value></Item></Value>
</Item>
</Map>
</CONTENT>
<TAIL/>
</Message>
</Messages>
我想根据name获取值,也就是说根据name获取到indexNum的值,怎么获取啊,谢谢了 JavaXML节点值
解决方案 »
- hibernate发生GenericJDBCException: could not insert collection
- 动态checkbox 在修改页面中如何被选中
- 怎样得到Jtable中的最后一行的数据
- 大家帮帮忙,这个flash是用什么java flash图表工具完成的?
- JSP页面打印发票的功能问题!
- 给每个用户建立一个子文件夹可取吗?有什么性能影响?
- Hibernate HQL的问题
- .jsp必须放在tomcat目录下才能运行吗?
- 请ejb高手帮忙!
- JAVA代理Proxy.newProxyInstance的疑问
- 客户端访问【webservice】报错,wsdl文档正常
- excel空单元格导入报错问题
<Item>
<Key>name</Key>
<Value>indexNum</Value>
</Item>
<Item>
<Key>jgdm</Key>
<Value>0105</Value>
</Item>
</Value>
是这一段吗,通过name获取indexNum,通过jgdm获取0105?
这段代码我拷了三遍了
/**
* 读取xml文件
* @param fileName
*/
void parserXml(String fileName)
{
File inputXml=new File(fileName);
SAXReader saxReader = new SAXReader();
try {
Document document = saxReader.read(inputXml); //把文件读入到文档
Element barcodeInfo=document.getRootElement(); //获取文档根节点
this.doublexml(barcodeInfo);
} catch (DocumentException e) {
System.out.println(e.getMessage());
}
}
private void doublexml(Element ele)
{
StringBuilder sb = new StringBuilder();
for(Iterator i = ele.elementIterator();i.hasNext();)
{
Element node = (Element)i.next();
System.out.println("节点名:"+node.getName());
String nodeName = node.getName();
if(node.attributes()!=null && node.attributes().size()>0)
{
for(Iterator j = node.attributeIterator();j.hasNext();)
{
Attribute item = (Attribute)j.next();
System.out.print("属性名:"+item.getName()+"\t属性值:"+item.getValue()+"\n");
}
}
if(node.getText().length()>0)
{
System.out.println("节点值:"+node.getText());
String nodeText = node.getText();
}
if(node.elementIterator().hasNext())
{
this.doublexml(node);
}
}
}