473,408 Members | 1,743 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.

Load XML to DataSet Problem

The following is a small sample of my XML Data. When I
load it to a dataset it only loads the 'Zone' elements
and ignores loading the 'Field' elements.
<zone id="1234" name="EMPLOYMENT_INFO">
<field change-date="00:00:00:000" display="true"
editable="true" name="SBSB_CK"
valid="true">22514850</field></zone>

<zone id="1235" name="SUBSCRIBER_INFO">
<field change-date="00:00:00:000" display="false"
editable="true" name="SBSB_CK"
valid="true">22514850</field></zone>

I use XPath to extract my Nodes and I use the following
to put the extracted Nodes into a DataSet:
Dim zones As System.Xml.XmlNode = CType
(ni.Current,System.Xml.IHasXmlNode).GetNode()
CnvXML += zones.OuterXml

Add back the Hdr/Footer to make it a valid XML Document,
without this step it would not load the DataSet at all.

Dim XMLHdr, XMLFooter As String
XMLHdr = "<?xml version='1.0' encoding='utf-8'?><ROOT>"
XMLFooter = "</ROOT>"
sXML = XMLHdr + sXML + XMLFooter

I then load it into a DataSet;
Dim ds As DataSet = New DataSet
Dim nSR As StringReader = New StringReader(sXML)
Dim xmlRdr As System.Xml.XmlTextReader = New
System.Xml.XmlTextReader(nSR)ds.ReadXml(xmlRdr,
XmlReadMode.InferSchema)
Nov 12 '05 #1
1 4537
I suggest you create a DataSet with multiple element types (you can do this
either manually, or by populating a dataset with 2 distinct queries, or
maybe with a union query, etc.), then serialize it and examine the results.
Your raw XML should follow that pattern in order to be accepted as a
dataset.


"Tom G" <an*******@discussions.microsoft.com> wrote in message
news:0e****************************@phx.gbl...
The following is a small sample of my XML Data. When I
load it to a dataset it only loads the 'Zone' elements
and ignores loading the 'Field' elements.
<zone id="1234" name="EMPLOYMENT_INFO">
<field change-date="00:00:00:000" display="true"
editable="true" name="SBSB_CK"
valid="true">22514850</field></zone>

<zone id="1235" name="SUBSCRIBER_INFO">
<field change-date="00:00:00:000" display="false"
editable="true" name="SBSB_CK"
valid="true">22514850</field></zone>

I use XPath to extract my Nodes and I use the following
to put the extracted Nodes into a DataSet:
Dim zones As System.Xml.XmlNode = CType
(ni.Current,System.Xml.IHasXmlNode).GetNode()
CnvXML += zones.OuterXml

Add back the Hdr/Footer to make it a valid XML Document,
without this step it would not load the DataSet at all.

Dim XMLHdr, XMLFooter As String
XMLHdr = "<?xml version='1.0' encoding='utf-8'?><ROOT>"
XMLFooter = "</ROOT>"
sXML = XMLHdr + sXML + XMLFooter

I then load it into a DataSet;
Dim ds As DataSet = New DataSet
Dim nSR As StringReader = New StringReader(sXML)
Dim xmlRdr As System.Xml.XmlTextReader = New
System.Xml.XmlTextReader(nSR)ds.ReadXml(xmlRdr,
XmlReadMode.InferSchema)

Nov 12 '05 #2

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

Similar topics

6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
1
by: Soul | last post by:
Hi, I have a DataGrid which works. But if I load a new table to the DataGrid, it will still show those old data I load earlier. private void loadTableA() { if ( openFileDialog.ShowDialog()...
4
by: jaime | last post by:
1 I load a text file into a dataset, after doing a bit of work.. 2 Now I have a dataset full of data that I like to transfer to a data base 3 My problem is that if the rowstate of the row is set to...
1
by: Seema | last post by:
Hello I am trying to create a normal report , i tried 3 ways. 1. Connecting to SQL db table 2. Creating dataset.xsd and using the same as datasource while creating a report and passing ...
9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
0
by: newsaboutgod | last post by:
I am loading a dataset from a XML file. I want to allow the user to display data from the dataset in a grid. Depending on which button they click i want to load the grid with a subset of data...
0
by: =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post by:
Hi all, I have a weird problem which has been causing me a headache for the last two days. I have to dynamicly generate a schema in memory and load it into a dataset in memory to be returned...
1
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have problems loading XML data into SQL Server. What is the best way to go ? I am new in using XML documents. I have tried to do it with "Integration Services" and also with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.