0
我想使用LINQ-to-XML檢索下列xml的子元素(屬性)作爲字典 ?檢索Xml節點子元素作爲詞典
所謂當
Dictionary<String,String> dict = ReadFromXml("TC_001","L3")
我應該能夠檢索控制 UID = 「L3」 ControlList ID = 「TC_001」 作爲 名稱,在字典值對作爲
[「id」,「googlelink」]
[「name」,null]
[「class」,null]
。
。
。
<?xml version="1.0"?>
<ControlList id="TC_001">
<Control uid="L1">
<Property name="Id"> <![CDATA[googlelink]]></Property>
<Property name="Name"> null </Property>
<Property name="Target"> null </Property>
<Property name="Innertext"> <![CDATA["Try searching me www.google.com"]]></Property>
<Property name="Href"> <![CDATA["http://www.google.com/"]]></Property>
</Control>
<Control uid="L2">
<Property name="Id"> <![CDATA[googlelink]]></Property>
<Property name="Name"> null </Property>
<Property name="Class"> null </Property>
<Property name="ControlDefinition"> <![CDATA["id=googlelink href=\"http://www.google.co"]]> </Property>
<Property name="TagInstance"> 1 </Property>
</Control>
<Control uid="L3">
<Property name="Id"> <![CDATA[googlelink]]></Property>
<Property name="Name"> null </Property>
<Property name="Target"> null </Property>
<Property name="Innertext"> <![CDATA["Try searching me www.google.com"]]></Property>
</Control>
</ControlList>
編輯8/1:同樣的問題不同的xml結構。 (節點不具有名稱「屬性」現在)
<?xml version="1.0"?>
<ControlList id="TC_001">
<Control uid="L1">
<Id> <![CDATA[googlelink]]><Id>
<Name> null </Name>
<Target> null </Target>
<Innertext> <![CDATA["Try searching me www.google.com"]]></Innertext>
</Control>
<!-- more multiple controls similar to above-->
</ControlList>
是的ID將始終存在 – Amitd 2011-01-08 02:12:10