XML理解困难,我得到了这个特定的XML文件,它看起来像这样:XML - 解析使用JDOM
<App01_Storage Type="VOLATILE" Size="200000" Speed="15" LatencyMaxWrite="1" LatencyMaxRead="2" Endurance="12" WorkloadPeak="15" />
在我的节目,我通过根节点的所有儿童进行迭代。我的意图是让所有的孩子都拥有属性+值。一个孩子看起来像上面的代码。
System.out.println(node.getName());
System.out.println(node.getAttributes());
的System.out的法给了我这样的输出: App01_Storage [属性:TYPE = “挥发性”] [属性:尺寸= “200000”] [属性:速度= “15” ] [属性:LatencyMaxWrite =“1”],[Attribute:LatencyMaxRead =“2”],[Attribute:Endurance =“12”],[Attribute:WorkloadPeak =“15”]]
我想我是在正确的方式。根据我的理解,一个属性应该看起来像这样:Attribute.Name = Attribute.Value
我想将属性加上值保存在不同的类中,并且不知道如何确切地获得值和名称separetaly。我现在得到的输出是一个List,每个条目Attributename = Attributevalue,就像一个String。有了这个单一的字符串,我无法工作。
我看到有什么问题吗?希望我能解释一下自己。非常感谢:)