2009-12-28 63 views
1

我有这种xml数据格式。我想从中提取属性名称和值。我试图逐个获取节点,但这很麻烦。从Java中提取XML数据

<?xml version="1.0"> encoding="ASCII"?> 
<xDiagram> 
    <children iD="1261435145010.0" location="Point(547,184)" 
    size="Dimension(102,140)" shapeType="TestInfoShape" 
    modelEntityID="TestInfo.7"> 
    <properties> 
     <properties name="desc" type="MultiLinesText" 
     parent="this_comp1" parentName="multiLinesText" 
     modelPropName="desc" value="create test user can access"/> 
     <properties name="name" type="String" parent="this_comp2" 
     parentName="text" modelPropName="name" value="testCase1"/> 
    </properties> 
    </children> 
</xDiagram> 

任何人都可以提出一个更好的方法来做到这一点吗?我喜欢使用XPath,但无法锁定元素。

谢谢

+0

数据在哪里? – 2009-12-28 04:03:46

+0

做了一些编辑,很不够,但数据现在显示。 – Tom 2009-12-28 04:12:24

+0

该XML无效。 Copy'n'paste错误?或者也是真实的? – BalusC 2009-12-28 04:31:56

回答