473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Can we populate a XML formated string into a dataset?

When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., datset.read(string filename), dataset.readxml(string
filename)).

If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David
Mar 29 '07 #1
6 1712
http://www.google.com/search?hl=en&q...+to+dataset%22

There's good info in the links returned by that Google query.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"david" <da***@discussions.microsoft.comwrote in message
news:A2**********************************@microsof t.com...
When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., datset.read(string filename), dataset.readxml(string
filename)).

If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David

Mar 29 '07 #2
I have searched Yahoo and Microsoft web, some info seems useful but doesn't
work.

I will try to find some.

David

"Juan T. Llibre" wrote:
http://www.google.com/search?hl=en&q...+to+dataset%22

There's good info in the links returned by that Google query.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"david" <da***@discussions.microsoft.comwrote in message
news:A2**********************************@microsof t.com...
When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., datset.read(string filename), dataset.readxml(string
filename)).

If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David


Mar 29 '07 #3
Here's a quick example :

<%@ Import Namespace="System.Data" %>
<script runat="server">
sub Page_Load(sender as Object, e as EventArgs)
Dim myDataSet as New DataSet()

myDataSet.ReadXml(Server.MapPath("some.xml"))

dgSome.DataSource = myDataSet
dgSome.DataBind()
end sub
</script>

<body>
<asp:datagrid id="dgSome" runat="server" />
</body>

If you are getting the XML from a stream,
you'll need to write it to disk before using this method.

That shouldn't present too many complications.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"david" <da***@discussions.microsoft.comwrote in message
news:81**********************************@microsof t.com...
>I have searched Yahoo and Microsoft web, some info seems useful but doesn't
work.

I will try to find some.

David
"Juan T. Llibre" wrote:
>http://www.google.com/search?hl=en&q...+to+dataset%22

There's good info in the links returned by that Google query.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"david" <da***@discussions.microsoft.comwrote in message
news:A2**********************************@microso ft.com...
When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., dataset.read(string filename), dataset.readxml(string filename)).
If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David

Mar 29 '07 #4
Incase you have yr xml in the form of a string and not a physical .xml file
on the server, in that case you could try this option.

Load the string into an StringReader object and the same can be passed to
the ReadXml method of the dataset.

StringReader strReader = new StringReader(str);
DataSet _ds = new DataSet();
_ds.ReadXml(strReader);
Response.Write(_ds.GetXml());

This should work.
Mar 29 '07 #5
Thanks
I will try your stringreader.

David

"Parvathy Padmanabhan" wrote:
Incase you have yr xml in the form of a string and not a physical .xml file
on the server, in that case you could try this option.

Load the string into an StringReader object and the same can be passed to
the ReadXml method of the dataset.

StringReader strReader = new StringReader(str);
DataSet _ds = new DataSet();
_ds.ReadXml(strReader);
Response.Write(_ds.GetXml());

This should work.
Mar 30 '07 #6
Thanks for all of you.

StringReader makes the program work.

David

"Parvathy Padmanabhan" wrote:
Incase you have yr xml in the form of a string and not a physical .xml file
on the server, in that case you could try this option.

Load the string into an StringReader object and the same can be passed to
the ReadXml method of the dataset.

StringReader strReader = new StringReader(str);
DataSet _ds = new DataSet();
_ds.ReadXml(strReader);
Response.Write(_ds.GetXml());

This should work.
Mar 30 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Goldsworth_Systems | last post by:
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?
7
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data...
9
by: Mike L | last post by:
I tried a sample of code in MSDN magazine, but now I'm stuck. What code has the best performance to populate a Data Grid with a SP? Below is the code I have, which might be completing the wrong...
3
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to...
3
by: crjunk | last post by:
I have 4 different databases that I'm having to pull data from in order to populate a datagrid. I am able to do this, but my problem is that because I'm pulling the data from 4 different...
3
by: Paul D. Fox | last post by:
I would like to read from Active Directory and populate a dataset to be passed in a Web Service. I can get the data from AD just fine, but can I populate a dataset with these values and do a...
16
by: Mike Fellows | last post by:
when i load my windows form i populate a combobox i use the code below Dim conn As New System.Data.SqlClient.SqlConnection(strConn) Dim sql As String = "AllLenders" Dim da As New...
2
by: paumierj | last post by:
Hi there Here's my question : I'd like to populate a dataset from an XML string, ie: Dim sXmlString As String sXmlString = "<root type='E-Form'><question label='This is my first...
2
by: Tim Kelley | last post by:
Is it possible to populate a grid using code (not binding it to a datasource). Is there something like an additem method? Thanks,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.