I've XML file structure for single table node as below
我有单表节点的XML文件结构,如下所示
<table ID="123" Name="Prj">
<select>
<slno>prjslno</slno>
<to>prjrecepient</to>
<from>prjsender</from>
<body>prjcontent</body>
</select>
<where>status="new"</where>
<successupdate>
<status>'mail sent'</status>
</successupdate>
<failureupdate>
<status>'mail sending failed'</status>
</failureupdate>
</table>
There are 3 such nodes in my xml file. I need to traverse the xml file and store the content in hashmap.I've tried to store them in the following format
我的xml文件中有3个这样的节点。我需要遍历xml文件并将内容存储在hashmap中。我试图以下列格式存储它们
key value
slno prjslno
to prjrecepient
from prjsender
body prjcontent
where status="new"
But when I tried to store the status and its value for success and failure updates its getting overwritten and storing 'mail sending failed' value but not 'mail sent'.( I know the reason as the hashmap supports unique key so its storing in this way).
但是当我试图存储状态及其成功和失败的值时,它会被覆盖并存储“邮件发送失败”值而不是“邮件发送”。(我知道原因,因为hashmap支持唯一键,因此它存储在此办法)。
But I need to store them in hashmap for the later use. Is there any way to sort out? please suggest something.
但我需要将它们存储在hashmap*以后使用。有什么方法可以理清吗?请提出建议。
1 个解决方案
#1
0
I'd create composite keys from the current and it's parent element name, like:
我将从当前及其父元素名称创建复合键,如:
map.put("succesupdate/status", "'mail sent'");
map.put("failureupdate/status", "'mail sending failed'");
It will not work in general but could be a solution for your current problem.
它一般不起作用,但可以解决您当前的问题。
#1
0
I'd create composite keys from the current and it's parent element name, like:
我将从当前及其父元素名称创建复合键,如:
map.put("succesupdate/status", "'mail sent'");
map.put("failureupdate/status", "'mail sending failed'");
It will not work in general but could be a solution for your current problem.
它一般不起作用,但可以解决您当前的问题。