|
-
Sep 17th, 2004, 06:11 AM
#1
Thread Starter
Lively Member
Binding a string of xml to a datagrid
Hiya,
This is probably really easy to do but i am struggling 
Does anyone know how i can bind a string of xml that i create on the fly to a datagrid. I know how to do it using a xml file but i have no idea how to do it using a string of xml
Any help would be fantastic
Thanks
Sarah
-
Sep 19th, 2004, 07:18 AM
#2
I wonder how many charact
You have to put your string into a IO stream... then feed that to the ReadXML method of datast, plugging that into the DataGrid.
VB Code:
Imports System.IO
Imports System.Text
Dim ioArray As Byte() = _
uniEncoding.GetBytes(xmlstring)
Dim memStream As New IO.MemoryStream
memStream.Write(ioArray, 0 , ioArray.Length)
memStream.Seek(0, SeekOrigin.Begin)
MyDataset.ReadXML(memStream)
MyDataGrid1.DataSource = MyDataSet
From MSDN:
Note
If the XSD schema for a DataSet includes a targetNamespace, data may not be read, and you may encounter exceptions when calling ReadXml to load the DataSet with XML that contains elements with no qualifying namespace. To read unqualified elements, set elementFormDefault equal to "qualified" in your XSD schema as the following example demonstrates.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|