473,700 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stream DataSet into XMLDocument

Hello,

I am trying to create a xmlDocument from as dataset. My code is listed
below. All seems to go well until
xmlDocument.Loa d(CType(ms, System.IO.Strea m)) ... I keep getting the
following error "The Root Element is Missing" ... any help would be
appreciated.

Thanks,
Rob Panosh

Public Function GetXMLDocument( ) As System.String
Dim xDataSet As New System.Data.Dat aSet
Dim xmlDocument As New System.Xml.XmlD ocument
Dim ms As New System.IO.Memor yStream ' = Nothing
Dim ser As System.Xml.Seri alization.XmlSe rializer
Dim t As System.Type

t = GetType(System. Data.DataSet)
ser = New System.Xml.Seri alization.XmlSe rializer(t) '
System.Type.Get Type("System.Da ta.DataSet"))

'Filled with data adapter.
Me.Execute(xDat aSet, "test")

ser.Serialize(m s, xDataSet)
xmlDocument.Loa d(CType(ms, System.IO.Strea m))

End Function
Nov 20 '05 #1
5 10163
The error tells me that what you are trying to load into an XMLDocument is
not well-formed XML.

Have you printed out the data that "ms" contains? Also, you seem to be
going though excessive trouble to take the DataSet data and persist it as
xml when a DataSet has a getXML() method that will do what you want:
Public Function GetXMLDocument( ) As System.String
Dim xDataSet As New System.Data.Dat aSet
Dim xmlDocument As New System.Xml.XmlD ocument

'....Fill your DataSet here...

'Convert the DataSet data to XML and load it into the
XMLDocument
xmlDocument.Loa d(xDataSet.GetX ML())
End Function

"Rob Panosh" <ro************ ************@as dsoftadfdware.c om> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello,

I am trying to create a xmlDocument from as dataset. My code is listed
below. All seems to go well until
xmlDocument.Loa d(CType(ms, System.IO.Strea m)) ... I keep getting the
following error "The Root Element is Missing" ... any help would be
appreciated.

Thanks,
Rob Panosh

Public Function GetXMLDocument( ) As System.String
Dim xDataSet As New System.Data.Dat aSet
Dim xmlDocument As New System.Xml.XmlD ocument
Dim ms As New System.IO.Memor yStream ' = Nothing
Dim ser As System.Xml.Seri alization.XmlSe rializer
Dim t As System.Type

t = GetType(System. Data.DataSet)
ser = New System.Xml.Seri alization.XmlSe rializer(t) '
System.Type.Get Type("System.Da ta.DataSet"))

'Filled with data adapter.
Me.Execute(xDat aSet, "test")

ser.Serialize(m s, xDataSet)
xmlDocument.Loa d(CType(ms, System.IO.Strea m))

End Function

Nov 20 '05 #2
Scott,

I am trying to get a xmlDocument that can easily be manipulated at runtime.

Rob

"Scott M." <s-***@BADSPAMsnet .net> wrote in message
news:eu******** ******@TK2MSFTN GP09.phx.gbl...
The error tells me that what you are trying to load into an XMLDocument is
not well-formed XML.

Have you printed out the data that "ms" contains? Also, you seem to be
going though excessive trouble to take the DataSet data and persist it as
xml when a DataSet has a getXML() method that will do what you want:
Public Function GetXMLDocument( ) As System.String
Dim xDataSet As New System.Data.Dat aSet
Dim xmlDocument As New System.Xml.XmlD ocument

'....Fill your DataSet here...

'Convert the DataSet data to XML and load it into the
XMLDocument
xmlDocument.Loa d(xDataSet.GetX ML())
End Function

"Rob Panosh" <ro************ ************@as dsoftadfdware.c om> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello,

I am trying to create a xmlDocument from as dataset. My code is listed
below. All seems to go well until
xmlDocument.Loa d(CType(ms, System.IO.Strea m)) ... I keep getting the
following error "The Root Element is Missing" ... any help would be
appreciated.

Thanks,
Rob Panosh

Public Function GetXMLDocument( ) As System.String
Dim xDataSet As New System.Data.Dat aSet
Dim xmlDocument As New System.Xml.XmlD ocument
Dim ms As New System.IO.Memor yStream ' = Nothing
Dim ser As System.Xml.Seri alization.XmlSe rializer
Dim t As System.Type

t = GetType(System. Data.DataSet)
ser = New System.Xml.Seri alization.XmlSe rializer(t) '
System.Type.Get Type("System.Da ta.DataSet"))

'Filled with data adapter.
Me.Execute(xDat aSet, "test")

ser.Serialize(m s, xDataSet)
xmlDocument.Loa d(CType(ms, System.IO.Strea m))

End Function


Nov 20 '05 #3
Cor
Hi Rob,

If you want an simple approach, create your dataset using the designer to
make an XSD, that is the most easy method you can reference to that when you
create your new dataset in your program.

If you want you can also create it in code(not that difficult).

Than you can do a mydataset.write xml(path) and readxml and you have your
dateset.

Know that there are a lot of overloaded functions with datasets and
datatables.

So there is not always one way.

I hope this gives some idea's?

Cor
Nov 20 '05 #4
Cor,

Yes that is true .... I was trying to avoid writing a file to disk. I have
it all sorted out.

Thanks for your input.

Rob

"Cor" <no*@non.com> wrote in message
news:ud******** ******@TK2MSFTN GP12.phx.gbl...
Hi Rob,

If you want an simple approach, create your dataset using the designer to
make an XSD, that is the most easy method you can reference to that when you create your new dataset in your program.

If you want you can also create it in code(not that difficult).

Than you can do a mydataset.write xml(path) and readxml and you have your
dateset.

Know that there are a lot of overloaded functions with datasets and
datatables.

So there is not always one way.

I hope this gives some idea's?

Cor

Nov 20 '05 #5
The code I gave will give you your XMLDocument without the whole trouble of
setting up the stream and serializing.
"Rob Panosh" <ro************ ************@as dsoftadfdware.c om> wrote in
message news:u7******** ******@TK2MSFTN GP09.phx.gbl...
Scott,

I am trying to get a xmlDocument that can easily be manipulated at runtime.
Rob

"Scott M." <s-***@BADSPAMsnet .net> wrote in message
news:eu******** ******@TK2MSFTN GP09.phx.gbl...
The error tells me that what you are trying to load into an XMLDocument is not well-formed XML.

Have you printed out the data that "ms" contains? Also, you seem to be
going though excessive trouble to take the DataSet data and persist it as xml when a DataSet has a getXML() method that will do what you want:
Public Function GetXMLDocument( ) As System.String
Dim xDataSet As New System.Data.Dat aSet
Dim xmlDocument As New System.Xml.XmlD ocument

'....Fill your DataSet here...

'Convert the DataSet data to XML and load it into the
XMLDocument
xmlDocument.Loa d(xDataSet.GetX ML())
End Function

"Rob Panosh" <ro************ ************@as dsoftadfdware.c om> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello,

I am trying to create a xmlDocument from as dataset. My code is listed
below. All seems to go well until
xmlDocument.Loa d(CType(ms, System.IO.Strea m)) ... I keep getting the
following error "The Root Element is Missing" ... any help would be
appreciated.

Thanks,
Rob Panosh

Public Function GetXMLDocument( ) As System.String
Dim xDataSet As New System.Data.Dat aSet
Dim xmlDocument As New System.Xml.XmlD ocument
Dim ms As New System.IO.Memor yStream ' = Nothing
Dim ser As System.Xml.Seri alization.XmlSe rializer
Dim t As System.Type

t = GetType(System. Data.DataSet)
ser = New System.Xml.Seri alization.XmlSe rializer(t) '
System.Type.Get Type("System.Da ta.DataSet"))

'Filled with data adapter.
Me.Execute(xDat aSet, "test")

ser.Serialize(m s, xDataSet)
xmlDocument.Loa d(CType(ms, System.IO.Strea m))

End Function



Nov 20 '05 #6

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

Similar topics

1
5764
by: Matt M | last post by:
Hey, I'm trying to pass an XML document from a webservice to another assembly. What I'd like to do is pass either an XML document or a dataset, so I figure that if I can turn the Dataset into an XMLDocument, then in my assembly, return that XMLDocument back to the dataset (if it is one), I will be good to go. Problem is, I haven't been able to find out how to transform a dataset into
2
9078
by: Steve Gilbey | last post by:
I have a dataset from which I need to extract certain columns, format them into xml and output to an xmldocument object. From reading various posts on similar subjects, I have come up with the following test code (using 2 constants, rather than my dataset values): Public Sub test() Dim doc As New XmlDocument Dim xmlStream As Stream = New MemoryStream
6
7352
by: Yechezkal Gutfreund | last post by:
I have been using the following code (successfully) to read Xml formated text packets from a TCP stream. The output from the server stream consists of a sequence of well formed Xml documents written to the output stream. We are willing to pay $ to any expert (e.g. MVP) consultant who has to time to help us track down this problem. (we will discuss rates if you can prove your expertise, and problem solving approach).
3
9564
by: Tom Vukovich | last post by:
and returning the xml to the requesting web page, how do you insert the XML declaration? ds.EnforceConstraints = False Response.ContentType = "text/xml" ds.WriteXml(Response.OutputStream, XmlWriteMode.IgnoreSchema) I would like to add <?xml version="1.0" ?>
5
17699
by: Drew Yallop | last post by:
I read an XML file with a stream reader in VB.Net. When I look at the stream reader output in debug mode (by passing cursor over the stream reader object)the format is a perfect replica of the file as displayed when I open the xml file in VS .net 2003 IDE. When I perform the same procedure in C# the stream reader obkect displays a chaotic mess. Lots of whitespace after and "\r" and "\n" after each element. The problem is that I cannot...
4
3568
by: Samuel R. Neff | last post by:
I'm deserializing an XML file. If I pass a Stream to the file directly to the deserializer as follows it works fine: o = (New XmlSerializer( GetType( CompensationPackage))).Deserialize(stream) But if I pass an XmlNodeReader to the deserializer it doesn't work:
1
2673
by: M. Posseth | last post by:
Hello i have a problem i have this peace of code Dim xmldoc As XmlDocument = fobjXMLSendXMLRequest(strXml) Dim nodeData As XmlNode = xmldoc.SelectSingleNode("tirep").Item("data") Dim strdata As String = "<data>" & nodeData.InnerXml & "</data>"
7
3362
by: =?Utf-8?B?ZG91Zw==?= | last post by:
Have loaded balanced web servers that we do not allow to connect to our database. Content is created and pushed to these sites. I want to add a web service that may get multiple requests a second depending on peak access. I have built an XML file from SQL DB and pushed this file to web server. I want to load XML file at application startup and leave it cached if possible (it will vary in size from 1-2MB) and treat it like an SQL table...
11
2887
by: casucci | last post by:
I do a return as XMLDataDocument in my webservice but it returns not with the namespaces etc in them. Anyone have and example where I can have the webservice return it as a XML. C# preferred. Flash just sees it as an object when it calls the web service. Thanks
0
8714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
8641
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9203
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8958
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8912
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5897
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2379
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.