Dim objXMLSR As System.IO.StringReader = New System.IO.StringReader(xmlResponseString)
Dim objDS As New DataSet
objDS.ReadXml(objXMLSR, XmlReadMode.IgnoreSchema)
gridOutput.DataSource = objDS.Tables("user")
Dim xmlDocument = New XmlDocument()
xmlDocument.Load("Ur xml path") ' or xmlDocument.LoadXml(xmlResponseString)
Dim xmlReader = New XmlNodeReader(xmlDocument)
Dim dataSet = New DataSet()
dataSet.ReadXml(xmlReader)
Dim userTable = dataSet.Tables("user")
I'm trying to turn the xml below into a dataset / datatable so I can display it in a gridview but it's returning 0 tables? Anythoughts?
Hello:)
I think you should simplify your root tag to only one,and you can use DataSet.ReadXml to import the whole xml contents into a DataTable by referring its public property of——DataSet.Tables[0],please check this out:
Dim xmlDocument = New XmlDocument()
xmlDocument.Load("Ur xml path") ' or xmlDocument.LoadXml(xmlResponseString)
Dim xmlReader = New XmlNodeReader(xmlDocument)
Dim dataSet = New DataSet()
dataSet.ReadXml(xmlReader)
Dim userTable = dataSet.Tables("user")
Sorry but your answer isn't correct——Have you tried before pasting them out?And your output cannot output the value of
authentication,it's 0!!!
The reason is just the xml formation cannot be recognized by the XmlDocument or DataSet directly!
Your xml formation doesn't seem right,would you mind re-formatting them?
Hi TimoYang:)
My codes have been all well-formatted,and here's my codes(the xml contents are also formatted well above……)So you can check it out:
Module A
Public Sub main()
Dim xmlDocument = New XmlDocument()
xmlDocument.Load("abc.xml")
Dim xmlReader = New XmlNodeReader(xmlDocument)
Dim dataSet = New DataSet()
dataSet.ReadXml(xmlReader)
Dim userTable = dataSet.Tables("user")
For Each r As DataRow In userTable.Rows
For Each c As DataColumn In userTable.Columns
Console.Write(r(c).ToString() & "<===>")
Next
Console.WriteLine()
Next
End Sub
End Module
And I've do some modifications to the codes from Decker to check your codes!!!
Module A
Public Sub main()
Dim xmlDocument = New XmlDocument()
xmlDocument.Load("abc.xml") ' or xmlDocument.LoadXml(xmlResponseString)
Dim xmlReader = New XmlNodeReader(xmlDocument)
Dim dataSet = New DataSet()
dataSet.ReadXml(xmlReader)
Dim userTable = dataSet.Tables("user")
For Each row As DataRow In userTable.Rows
For Each col As DataColumn In userTable.Columns
Console.Write(row(col).ToString() + "<===>")
Next
Console.WriteLine()
Next
End Sub
End Module
Sorry Mate, but did u explore the other tables in the dataset(output)?. There is an another table called 'Authentication' in it in which u could find the values/data u r expecting.
If u wanna see everything in the 'user' table then u should go with what
Decker Dong suggested.
bluelinenetw...
Member
139 Points
218 Posts
DataSet.XMLRead not making any tables
May 23, 2012 08:31 PM|LINK
Hi all,
I'm trying to turn the xml below into a dataset / datatable so I can display it in a gridview but it's returning 0 tables? Anythoughts?
<configuration> <system> <login> <user> <name>joeuser</name> <uid>2001</uid> <class>xyz</class> <authentication> <encrypted-password>askldjfc;acmealsiefja;flcnsdlkm</encrypted-password> </authentication> </user> <user> <name>bobuser</name> <uid>2002</uid> <class>xyz</class> <authentication> <encrypted-password>askldjfc;acmealsiefja;flcnsdlkm</encrypted-password> </authentication> </user> <user> <name>joeuser</name> <uid>2002</uid> <class>xyz</class> <authentication> <encrypted-password>askldjfc;acmealsiefja;flcnsdlkm</encrypted-password> </authentication> </user> </login> </system> </configuration>Dim objXMLSR As System.IO.StringReader = New System.IO.StringReader(xmlResponseString) Dim objDS As New DataSet objDS.ReadXml(objXMLSR, XmlReadMode.IgnoreSchema) gridOutput.DataSource = objDS.Tables("user")Web Based Self Service Password Reset for Active Directory Accounts (OpenSource Project)
Ramesh T
Contributor
5131 Points
827 Posts
Re: DataSet.XMLRead not making any tables
May 24, 2012 11:07 AM|LINK
Try this
Dim xmlDocument = New XmlDocument() xmlDocument.Load("Ur xml path") ' or xmlDocument.LoadXml(xmlResponseString) Dim xmlReader = New XmlNodeReader(xmlDocument) Dim dataSet = New DataSet() dataSet.ReadXml(xmlReader) Dim userTable = dataSet.Tables("user")chotai janki
Member
36 Points
8 Posts
Re: DataSet.XMLRead not making any tables
May 24, 2012 01:38 PM|LINK
Hi,
Try referencing this code
Dim myDataSet as New DataSet() myDataSet.ReadXml(Server.MapPath("xyx.xml")) dg.DataSource = myDataSet dg.DataBind()
Thanks!
---------------------------
Mark this post as answer, if it helped you
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: DataSet.XMLRead not making any tables
May 25, 2012 01:27 AM|LINK
Hello:)
I think you should simplify your root tag to only one,and you can use DataSet.ReadXml to import the whole xml contents into a DataTable by referring its public property of——DataSet.Tables[0],please check this out:
<configuration> <user> <name>joeuser</name> <uid>2001</uid> <class>xyz</class> <authentication>askldjfc;acmealsiefja;flcnsdlkm</authentication> </user> <user> <name>bobuser</name> <uid>2002</uid> <class>xyz</class> <authentication>your value2</authentication> </user> <user> <name>joeuser</name> <uid>2002</uid> <class>xyz</class> <authentication>your value3</authentication> </user> </configuration>And here's your code contents:
DataSet ds = new DataSet() ds.ReadXml("c:\\xxx.xml")TimoYang
Contributor
3732 Points
1275 Posts
Re: DataSet.XMLRead not making any tables
May 25, 2012 01:42 AM|LINK
Sorry but your answer isn't correct——Have you tried before pasting them out?And your output cannot output the value of
authentication,it's 0!!!The reason is just the xml formation cannot be recognized by the XmlDocument or DataSet directly!TimoYang
Contributor
3732 Points
1275 Posts
Re: DataSet.XMLRead not making any tables
May 25, 2012 01:47 AM|LINK
Hello Decker——
Your xml formation doesn't seem right,would you mind re-formatting them?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: DataSet.XMLRead not making any tables
May 25, 2012 02:01 AM|LINK
Hi TimoYang:)
My codes have been all well-formatted,and here's my codes(the xml contents are also formatted well above……)So you can check it out:
Module A Public Sub main() Dim xmlDocument = New XmlDocument() xmlDocument.Load("abc.xml") Dim xmlReader = New XmlNodeReader(xmlDocument) Dim dataSet = New DataSet() dataSet.ReadXml(xmlReader) Dim userTable = dataSet.Tables("user") For Each r As DataRow In userTable.Rows For Each c As DataColumn In userTable.Columns Console.Write(r(c).ToString() & "<===>") Next Console.WriteLine() Next End Sub End ModuleRamesh T
Contributor
5131 Points
827 Posts
Re: DataSet.XMLRead not making any tables
May 25, 2012 08:00 AM|LINK
@TimoYang
Yes, I did check and it works fine.
Wat do u mean?, posted xml is a well formed one.
can u clarify the below
The reason is just the xml formation cannot be recognized by the XmlDocument or DataSet directly!?TimoYang
Contributor
3732 Points
1275 Posts
Re: DataSet.XMLRead not making any tables
May 25, 2012 08:19 AM|LINK
Right?!So sure?!
Now look at your result!
joeuser<===>2001<===>xyz<===>0<===>0<===>
bobuser<===>2002<===>xyz<===>1<===>0<===>
joeuser<===>2002<===>xyz<===>2<===>0<===>
Can you see 0?!!!
And I've do some modifications to the codes from Decker to check your codes!!!
Module A Public Sub main() Dim xmlDocument = New XmlDocument() xmlDocument.Load("abc.xml") ' or xmlDocument.LoadXml(xmlResponseString) Dim xmlReader = New XmlNodeReader(xmlDocument) Dim dataSet = New DataSet() dataSet.ReadXml(xmlReader) Dim userTable = dataSet.Tables("user") For Each row As DataRow In userTable.Rows For Each col As DataColumn In userTable.Columns Console.Write(row(col).ToString() + "<===>") Next Console.WriteLine() Next End Sub End ModuleRamesh T
Contributor
5131 Points
827 Posts
Re: DataSet.XMLRead not making any tables
May 25, 2012 08:49 AM|LINK
Sorry Mate, but did u explore the other tables in the dataset(output)?. There is an another table called 'Authentication' in it in which u could find the values/data u r expecting.
If u wanna see everything in the 'user' table then u should go with what Decker Dong suggested.