我有一个XML文件,如下所示:
这只是一个片段,此XML中有大约100个表
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="row1" type="xs:string" minOccurs="0" />
<xs:element name="row2" type="xs:int" minOccurs="0" />
<xs:element name="row3" type="xs:string" minOccurs="0" />
<xs:element name="row4" type="xs:string" minOccurs="0" />
<xs:element name="row5" type="xs:string" minOccurs="0" />
<xs:element name="row6" type="xs:string" minOccurs="0" />
<xs:element name="row7" type="xs:decimal" minOccurs="0" />
<xs:element name="row8" type="xs:decimal" minOccurs="0" />
<xs:element name="row9" type="xs:string" minOccurs="0" />
<xs:element name="row10" type="xs:int" minOccurs="0" />
<xs:element name="row11" type="xs:string" minOccurs="0" />
<xs:element name="row12" type="xs:string" minOccurs="0" />
<xs:element name="row13" type="xs:string" minOccurs="0" />
<xs:element name="row14" type="xs:string" minOccurs="0" />
<xs:element name="row15" type="xs:string" minOccurs="0" />
<xs:element name="row16" type="xs:int" minOccurs="0" />
<xs:element name="row17" type="xs:int" minOccurs="0" />
<xs:element name="row18" type="xs:string" minOccurs="0" />
<xs:element name="row19" type="xs:string" minOccurs="0" />
<xs:element name="row20" type="xs:string" minOccurs="0" />
<xs:element name="row21" type="xs:int" minOccurs="0" />
<xs:element name="row22" type="xs:string" minOccurs="0" />
<xs:element name="row23" type="xs:string" minOccurs="0" />
<xs:element name="row24" type="xs:boolean" minOccurs="0" />
<xs:element name="row25" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Table>
<row1>9074A454308A4460AE7A557A294636E0</row1>
<row2>2</row2>
<row3>561B2BDC1A04455A8A2BC07FDB0D114C</row3>
<row4>3AJPUL78</row4>
<row5>Cancelled</row5>
<row6>09/10/2012</row6>
<row7>1562.8600</row7>
<row8>1537.8600</row8>
<row9>Valid</row9>
<row10>1</row10>
<row11>GBP</row11>
<row12>##,##0.00</row12>
<row13>Valid</row13>
<row14>Valid</row14>
<row15>Correct</row15>
<row16>943</row16>
<row17>26</row17>
<row18>Right</row18>
<row19>Mr</row19>
<row20>A364A37BFC9D4B4186DE735BC0DFB01A</row20>
<row21>1</row21>
<row22>Firstname</row22>
<row23>Fwtxweb1</row23>
<row24>false</row24>
<row25>Home</row25>
我希望能够查询XML并恢复所有具有 ROW20 ID = A364A37BFC9D4B4186DE735BC0DFB01A
的表格在我的代码背后,我已经开始这样做了,但我陷入困境。
VB.NET代码:
Protected Sub dtb_client_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
'**THIS FIND THE ID OF THE PARAMETER THAT ROW20 NEEDS**'
Dim country As String = TryCast(dtb_client.SelectedRow.FindControl("txtInsuredpartyID"), Label).Text
'**THIS PUT THE STRING INTO A XML FILE**'
Dim pols As String = CType(Session("brokerPolicies"), String)
Dim XMLFilitered As XmlDocument = New XmlDocument()
XMLFilitered.LoadXml(pols)
'**I AM TRYING TO QUERY THE XML FILE AND BRING BACK THE TABLES THAT HAVE THE
Dim buff As XmlNodeList = XMLFilitered.SelectNodes("//NewDataSet/Table/ROW20[.='A364A37BFC9D4B4186DE735BC0DFB01A']")
Dim returnstr As String = ""
For Each item As XmlNode In buff
returnstr += item.OuterXml
Next
End Sub
结论 - 我有一个XML文件,里面有大约100个表。我有一个ROW20 ID,想要查询XML文件并带回所有表格