In VB.Net How do I use XmlNodeReader with multiple items of the same type?

sharonmumbai

New Member
I wrote the following code:\[code\]Imports System.XmlImports System.Security.CryptographyImports System.IOPublic Class FormMainPrivate Sub btnGo_Click(sender As System.Object, e As System.EventArgs) Handles btnGo.Click Dim ds1 As New DataSet ds1 = NewGetRecords() DataGridView1.DataSource = ds1.Tables(0) Label1.Text = ds1.Tables(0).TableName If ds1.Tables.Count > 1 Then DataGridView2.DataSource = ds1.Tables(1) Label2.Text = ds1.Tables(1).TableName End IfEnd SubPublic Function NewGetRecords() As DataSet Dim ds As New DataSet Dim xd As New XmlDocument xd.LoadXml(TextBox1.Text) ds.ReadXml(New XmlNodeReader(xd)) Return dsEnd FunctionEnd Class\[/code\]Here is the XML Data I am using (and this works):\[code\]<?xml version="1.0"?><ABMDataSets><ABDataSet><OwnerLogin>demo</OwnerLogin><OwnerUniqueID>abcd</OwnerUniqueID><OwnerPassword>abcd</OwnerPassword><OwnerName>Demo Owner</OwnerName><Address1>324 East Wisconsin Avenue</Address1><Address2>Suite 423</Address2><Address3></Address3><City>Milwaukee</City><State>WI</State><Country>US</Country><PostalCode>53202</PostalCode><Phone>414-431-8775</Phone><Email>[email protected]</Email><PayPalAccount>[email protected]</PayPalAccount><PercentMarkup>5</PercentMarkup><JoinDate>2012-01-25 00:57:00</JoinDate><ReferredBy></ReferredBy><Active>1</Active></ABDataSet></ABMDataSets>\[/code\]What doesn't work is when I have multiple records (For example, there are two records similar to the above):\[code\]<?xml version="1.0"?><ABMDataSets><ABDataSet><OwnerLogin>demo</OwnerLogin><OwnerUniqueID>abcd</OwnerUniqueID><OwnerPassword>abcd</OwnerPassword><OwnerName>Demo Owner</OwnerName><Address1>324 East Wisconsin Avenue</Address1><Address2>Suite 423</Address2><Address3></Address3><City>Milwaukee</City><State>WI</State><Country>US</Country><PostalCode>53202</PostalCode><Phone>414-431-8775</Phone><Email>[email protected]</Email><PayPalAccount>[email protected]</PayPalAccount><PercentMarkup>5</PercentMarkup><JoinDate>2012-01-25 00:57:00</JoinDate><ReferredBy></ReferredBy><Active>1</Active><OwnerLogin>demo</OwnerLogin><OwnerUniqueID>abcd</OwnerUniqueID><OwnerPassword>abcd</OwnerPassword><OwnerName>Demo Owner</OwnerName><Address1>324 East Wisconsin Avenue</Address1><Address2>Suite 423</Address2><Address3></Address3><City>Milwaukee</City><State>WI</State><Country>US</Country><PostalCode>53202</PostalCode><Phone>414-431-8775</Phone><Email>[email protected]</Email><PayPalAccount>[email protected]</PayPalAccount><PercentMarkup>5</PercentMarkup><JoinDate>2012-01-25 00:57:00</JoinDate><ReferredBy></ReferredBy><Active>1</Active></ABDataSet></ABMDataSets>\[/code\]
 
Back
Top