Convert XML String to Dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have used XMLDataToString = DataSetForXML.GetXml() to get an XML string
from a dataset. I am looking for a way to create a dataset from this XML
string. I tried DataSetForXML.ReadXml(XMLDataToString) but I received error
messages. Does anyone know how to do this without creating a file (disk
copy) of this XML data? Thanks for your help.
Marc
 
Mark,
Notice that DataSet.ReadXml is overloaded. ReadXml(String) reads Xml from
the named file.

Have you tried ReadXml(TextReader)? Specifically with a StringReader?

Something like:

Dim reader As New System.Io.StringReader(XMLDataToString)
DataSetForXML.ReadXml(reader)

For details see:

http://msdn.microsoft.com/library/d.../html/frlrfSystemIOStringReaderClassTopic.asp

http://msdn.microsoft.com/library/d.../frlrfSystemDataDataSetClassReadXmlTopic3.asp

Hope this helps
Jay


|I have used XMLDataToString = DataSetForXML.GetXml() to get an XML string
| from a dataset. I am looking for a way to create a dataset from this XML
| string. I tried DataSetForXML.ReadXml(XMLDataToString) but I received
error
| messages. Does anyone know how to do this without creating a file (disk
| copy) of this XML data? Thanks for your help.
| Marc
 
Jay,
That worked great! Just when you think you have tried everything. Thanks
so much for your help.
Marc
 
I know this is almost a month old, but I was having the same challenges and
tried your suggestions. They worked fine, but now, how do I get to the
fields in the Dataset?? Do they 'magically' appear as
".Fields(<Fieldname>).Value" once the XML String is read??
 
Any help? Bueller? Bueller? NE1? NE1?
Bryan Dickerson said:
I know this is almost a month old, but I was having the same challenges and
tried your suggestions. They worked fine, but now, how do I get to the
fields in the Dataset?? Do they 'magically' appear as
".Fields(<Fieldname>).Value" once the XML String is read??
 
Bryan,
You can get the DataColumns of a DataTable via the DataTable.Columns
property.

For a complete explanation of Datasets, DataTables, & DataAdapters along
with how to use them. I would strongly recommend you read David Sceppa's
book "Microsoft ADO.NET - Core Reference" from MS Press. As it is both a
good tutorial on ADO.NET as well as a good desk reference once you know
ADO.NET.

Hope this helps
Jay


|I know this is almost a month old, but I was having the same challenges and
| tried your suggestions. They worked fine, but now, how do I get to the
| fields in the Dataset?? Do they 'magically' appear as
| ".Fields(<Fieldname>).Value" once the XML String is read??
|
| | > Mark,
| > Notice that DataSet.ReadXml is overloaded. ReadXml(String) reads Xml
from
| > the named file.
| >
| > Have you tried ReadXml(TextReader)? Specifically with a StringReader?
| >
| > Something like:
| >
| > Dim reader As New System.Io.StringReader(XMLDataToString)
| > DataSetForXML.ReadXml(reader)
| >
| > For details see:
| >
| >
http://msdn.microsoft.com/library/d.../html/frlrfSystemIOStringReaderClassTopic.asp
| >
| >
http://msdn.microsoft.com/library/d.../frlrfSystemDataDataSetClassReadXmlTopic3.asp
| >
| > Hope this helps
| > Jay
| >
| >
| > | > |I have used XMLDataToString = DataSetForXML.GetXml() to get an XML
string
| > | from a dataset. I am looking for a way to create a dataset from this
| > XML
| > | string. I tried DataSetForXML.ReadXml(XMLDataToString) but I received
| > error
| > | messages. Does anyone know how to do this without creating a file
(disk
| > | copy) of this XML data? Thanks for your help.
| > | Marc
| >
| >
|
|
 
Bryan,
MSDN (http://msdn.microsoft.com) although I prefer the online local help
over the web help, however the content is the same.

Plus a plethora of other sites, google on DataSet and/or DataTable...

I would strongly recommend Sceppa's book! As its both a good tutorial & a
good desk reference. Far "better" & more "complete" then anything thing else
I've seen on ADO.NET.

Hope this helps
Jay

| Do you know of anything online docs that might tell me something similar?
|
| | > Bryan,
| > You can get the DataColumns of a DataTable via the DataTable.Columns
| > property.
| >
| > For a complete explanation of Datasets, DataTables, & DataAdapters along
| > with how to use them. I would strongly recommend you read David Sceppa's
| > book "Microsoft ADO.NET - Core Reference" from MS Press. As it is both a
| > good tutorial on ADO.NET as well as a good desk reference once you know
| > ADO.NET.
| >
| > Hope this helps
| > Jay
| >
| >
| > | > |I know this is almost a month old, but I was having the same challenges
| > and
| > | tried your suggestions. They worked fine, but now, how do I get to
the
| > | fields in the Dataset?? Do they 'magically' appear as
| > | ".Fields(<Fieldname>).Value" once the XML String is read??
| > |
| > message
| > | | > | > Mark,
| > | > Notice that DataSet.ReadXml is overloaded. ReadXml(String) reads Xml
| > from
| > | > the named file.
| > | >
| > | > Have you tried ReadXml(TextReader)? Specifically with a
StringReader?
| > | >
| > | > Something like:
| > | >
| > | > Dim reader As New System.Io.StringReader(XMLDataToString)
| > | > DataSetForXML.ReadXml(reader)
| > | >
| > | > For details see:
| > | >
| > | >
| >
http://msdn.microsoft.com/library/d.../html/frlrfSystemIOStringReaderClassTopic.asp
| > | >
| > | >
| >
http://msdn.microsoft.com/library/d.../frlrfSystemDataDataSetClassReadXmlTopic3.asp
| > | >
| > | > Hope this helps
| > | > Jay
| > | >
| > | >
| > | > | > | > |I have used XMLDataToString = DataSetForXML.GetXml() to get an XML
| > string
| > | > | from a dataset. I am looking for a way to create a dataset from
| > this
| > | > XML
| > | > | string. I tried DataSetForXML.ReadXml(XMLDataToString) but I
| > received
| > | > error
| > | > | messages. Does anyone know how to do this without creating a file
| > (disk
| > | > | copy) of this XML data? Thanks for your help.
| > | > | Marc
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 
Oh, and I meant to answer with another question yesterday (but was at home
sick yesterday): I didn't find any "DataTable" or "DataColumn"
properties/methods on the Dataset class. So what am I not seeing?
 
Bryan,
DataTable & DataColumn are types.

Remember that a DataSet contains zero or more DataTables, that a DataTable
has one or more DataColumns, and zero or more DataRows.

In other words the DataSet has a Tables property that returns a
DataTableCollection type. The DataTableCollection contains a collection of
DataTables. The DataTable has a Columns property that returns a
DataColumnCollection type. The DataColumnCollection contains a collection of
DataColumns.

You may want to review this section of MSDN:

http://msdn.microsoft.com/library/d...cpguide/html/cpconaccessingdatawithadonet.asp

Specifically:

http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpconoverviewofadonet.asp

http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpcontheadonetdataset.asp

http://msdn.microsoft.com/library/d...s/cpguide/html/cpconcreatingusingdatasets.asp

http://msdn.microsoft.com/library/d...n-us/cpguide/html/cpconcreatingdatatables.asp

http://msdn.microsoft.com/library/d.../cpguide/html/cpconcreatingusingdataviews.asp

However I would strongly recommend you read the entire section & Sceppa's
book.

Hope this helps
Jay

| Oh, and I meant to answer with another question yesterday (but was at home
| sick yesterday): I didn't find any "DataTable" or "DataColumn"
| properties/methods on the Dataset class. So what am I not seeing?
|
| | > Bryan,
| > MSDN (http://msdn.microsoft.com) although I prefer the online local help
| > over the web help, however the content is the same.
| >
| > Plus a plethora of other sites, google on DataSet and/or DataTable...
| >
| > I would strongly recommend Sceppa's book! As its both a good tutorial &
a
| > good desk reference. Far "better" & more "complete" then anything thing
| > else
| > I've seen on ADO.NET.
| >
| > Hope this helps
| > Jay
| >
| > | > | Do you know of anything online docs that might tell me something
| > similar?
| > |
| > message
| > | | > | > Bryan,
| > | > You can get the DataColumns of a DataTable via the DataTable.Columns
| > | > property.
| > | >
| > | > For a complete explanation of Datasets, DataTables, & DataAdapters
| > along
| > | > with how to use them. I would strongly recommend you read David
| > Sceppa's
| > | > book "Microsoft ADO.NET - Core Reference" from MS Press. As it is
both
| > a
| > | > good tutorial on ADO.NET as well as a good desk reference once you
| > know
| > | > ADO.NET.
| > | >
| > | > Hope this helps
| > | > Jay
| > | >
| > | >
| > | > | > | > |I know this is almost a month old, but I was having the same
| > challenges
| > | > and
| > | > | tried your suggestions. They worked fine, but now, how do I get
to
| > the
| > | > | fields in the Dataset?? Do they 'magically' appear as
| > | > | ".Fields(<Fieldname>).Value" once the XML String is read??
| > | > |
| > | > message
| > | > | | > | > | > Mark,
| > | > | > Notice that DataSet.ReadXml is overloaded. ReadXml(String) reads
| > Xml
| > | > from
| > | > | > the named file.
| > | > | >
| > | > | > Have you tried ReadXml(TextReader)? Specifically with a
| > StringReader?
| > | > | >
| > | > | > Something like:
| > | > | >
| > | > | > Dim reader As New System.Io.StringReader(XMLDataToString)
| > | > | > DataSetForXML.ReadXml(reader)
| > | > | >
| > | > | > For details see:
| > | > | >
| > | > | >
| > | >
| >
http://msdn.microsoft.com/library/d.../html/frlrfSystemIOStringReaderClassTopic.asp
| > | > | >
| > | > | >
| > | >
| >
http://msdn.microsoft.com/library/d.../frlrfSystemDataDataSetClassReadXmlTopic3.asp
| > | > | >
| > | > | > Hope this helps
| > | > | > Jay
| > | > | >
| > | > | >
| > | > | > | > | > | > |I have used XMLDataToString = DataSetForXML.GetXml() to get an
| > XML
| > | > string
| > | > | > | from a dataset. I am looking for a way to create a dataset
from
| > | > this
| > | > | > XML
| > | > | > | string. I tried DataSetForXML.ReadXml(XMLDataToString) but I
| > | > received
| > | > | > error
| > | > | > | messages. Does anyone know how to do this without creating a
| > file
| > | > (disk
| > | > | > | copy) of this XML data? Thanks for your help.
| > | > | > | Marc
| > | > | >
| > | > | >
| > | > |
| > | > |
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 
Jay,
However I would strongly recommend you read the entire section & Sceppa's
book.
Nothing wrong with your message and advice, however we missed this probably
for more than a year now.

To let you deal in my friendly smile.

:-)

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top