472,127 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

How do I populate a DataSet from a XML string?

I have a string containing valid XML.
How do I populate a dataset based on the string, without reference to an XML
schema or writing the XML to file and reading it back in again?
Nov 12 '05 #1
2 9336


Goldsworth_Systems wrote:
I have a string containing valid XML.
How do I populate a dataset based on the string, without reference to an XML
schema or writing the XML to file and reading it back in again?


You need an XML schema I think that describes the structure of the XML,
then it is no problem to read in the XML into an XmlDataDocument. But
without a schema it is not possible to associate the XML with a DataSet,
whether the XML is read from a file or from a string doesn't really matter.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Hi - I think I've cracked it - the following code seems to work:

Public Shared Function bDSOpenFromXML(ByVal vsXML As String, ByRef wdsReturn
As DataSet) As Boolean
' Creates a dataset based on the specified XML string
' Returns true for success

Dim rdr As New System.IO.StringReader(vsXML)
wdsReturn = New DataSet
wdsReturn.ReadXml(rdr)

bDSOpenFromXML = True
End Function

"Martin Honnen" wrote:


Goldsworth_Systems wrote:
I have a string containing valid XML.
How do I populate a dataset based on the string, without reference to an XML
schema or writing the XML to file and reading it back in again?


You need an XML schema I think that describes the structure of the XML,
then it is no problem to read in the XML into an XmlDataDocument. But
without a schema it is not possible to associate the XML with a DataSet,
whether the XML is read from a file or from a string doesn't really matter.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JIM.H. | last post: by
3 posts views Thread by Paul D. Fox | last post: by
16 posts views Thread by Mike Fellows | last post: by
2 posts views Thread by Tim Kelley | last post: by
6 posts views Thread by =?Utf-8?B?ZGF2aWQ=?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.