我有以下格式的XML:基於多個XML閱讀屬性
<Accounts>
<Account ID="1" City="Bangalore" Amount="2827561.95" />
<Account ID="225" City="New York" Amount="12312.00" />
<Account ID="236" City="London" Amount="457656.00" />
<Account ID="225" City="London" Amount="23462.40" />
<Account ID="236" City="Bangalore" Amount="2345345.00" />
</Accounts>
這裏,是什麼讓一個帳戶的獨特屬性是和ID
的City
組合。
如何唯一讀取Amount
?如何讀取ID
和City
屬性組合的金額?
例如,我需要爲ID=225
和City=London
帳戶獲取Amount
。如果我使用如下代碼
Node.GetAttribute('ID')=225
它總是給我ID的第一個節點= 225
感謝你。
如何使用'Node.GetAttribute( 'ID')= 225'?你是用循環還是...? – 2012-04-12 07:00:01
是的,我在循環中使用它。像... Node:= rootNode.ChildNodes.FindNode('Accounts'); for i:= 0 to Node.ChildNodes.Count - 1 do begin childnode:= Node.ChildNodes [i]; if Node.HasAttribute('ID')then amount:= Node.GetAttribute('ID'); ...... .. – Pradeep 2012-04-12 10:15:44
然後你可以在if語句中添加第二個條件來比較'City'的內容。 – 2012-04-12 10:26:54