469,352 Members | 1,641 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

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 9249


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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.