Loading data from an XML string to a dataset


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Loading data from an XML string to a dataset

  1. #1
    Thomas Guest

    Loading data from an XML string to a dataset


    I just cannot find a code sample showing how to load data from an XML string
    to a dataset! Everything out there has samples loading from a file but not
    from a string. Does anyone has a sample loading from a string to a stream,
    to a dataset???

    Alternatively, when using the DataSet() property of an XmlDataDocument, one
    must first load the Schema. Here again it is looking for a stream?

    Help! this is driving me nuts.

  2. #2
    Paul Mc Guest

    Re: Loading data from an XML string to a dataset


    G'day Thomas.

    >I just cannot find a code sample showing how to load data from an XML string
    >to a dataset!


    Easily done (Note that you will have to supply the XML string yourself ie
    the GetXML() function) :

    Dim s As String = GetXML()
    Dim ds As System.Data.DataSet = New System.Data.DataSet()
    Dim StringReader As System.IO.StringReader = New System.IO.StringReader(s)
    ds.ReadXml(StringReader)

    Or, in shorter form:

    Dim ds As System.Data.DataSet = New System.Data.DataSet()
    ds.ReadXml(New System.IO.StringReader(GetXML()))



    HTH,
    Cheers,
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center