473,473 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Create 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.Load(CType(ms, System.IO.Stream)) ... 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.DataSet
Dim xmlDocument As New System.Xml.XmlDocument
Dim ms As New System.IO.MemoryStream ' = Nothing
Dim ser As System.Xml.Serialization.XmlSerializer
Dim t As System.Type

t = GetType(System.Data.DataSet)
ser = New System.Xml.Serialization.XmlSerializer(t) '
System.Type.GetType("System.Data.DataSet"))

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

ser.Serialize(ms, xDataSet)
xmlDocument.Load(CType(ms, System.IO.Stream))

End Function
Nov 20 '05 #1
5 10136
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.DataSet
Dim xmlDocument As New System.Xml.XmlDocument

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

'Convert the DataSet data to XML and load it into the
XMLDocument
xmlDocument.Load(xDataSet.GetXML())
End Function

"Rob Panosh" <ro************************@asdsoftadfdware.com> wrote in
message news:%2****************@tk2msftngp13.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.Load(CType(ms, System.IO.Stream)) ... 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.DataSet
Dim xmlDocument As New System.Xml.XmlDocument
Dim ms As New System.IO.MemoryStream ' = Nothing
Dim ser As System.Xml.Serialization.XmlSerializer
Dim t As System.Type

t = GetType(System.Data.DataSet)
ser = New System.Xml.Serialization.XmlSerializer(t) '
System.Type.GetType("System.Data.DataSet"))

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

ser.Serialize(ms, xDataSet)
xmlDocument.Load(CType(ms, System.IO.Stream))

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**************@TK2MSFTNGP09.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.DataSet
Dim xmlDocument As New System.Xml.XmlDocument

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

'Convert the DataSet data to XML and load it into the
XMLDocument
xmlDocument.Load(xDataSet.GetXML())
End Function

"Rob Panosh" <ro************************@asdsoftadfdware.com> wrote in
message news:%2****************@tk2msftngp13.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.Load(CType(ms, System.IO.Stream)) ... 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.DataSet
Dim xmlDocument As New System.Xml.XmlDocument
Dim ms As New System.IO.MemoryStream ' = Nothing
Dim ser As System.Xml.Serialization.XmlSerializer
Dim t As System.Type

t = GetType(System.Data.DataSet)
ser = New System.Xml.Serialization.XmlSerializer(t) '
System.Type.GetType("System.Data.DataSet"))

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

ser.Serialize(ms, xDataSet)
xmlDocument.Load(CType(ms, System.IO.Stream))

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.writexml(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**************@TK2MSFTNGP12.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.writexml(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************************@asdsoftadfdware.com> wrote in
message news:u7**************@TK2MSFTNGP09.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**************@TK2MSFTNGP09.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.DataSet
Dim xmlDocument As New System.Xml.XmlDocument

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

'Convert the DataSet data to XML and load it into the
XMLDocument
xmlDocument.Load(xDataSet.GetXML())
End Function

"Rob Panosh" <ro************************@asdsoftadfdware.com> wrote in
message news:%2****************@tk2msftngp13.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.Load(CType(ms, System.IO.Stream)) ... 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.DataSet
Dim xmlDocument As New System.Xml.XmlDocument
Dim ms As New System.IO.MemoryStream ' = Nothing
Dim ser As System.Xml.Serialization.XmlSerializer
Dim t As System.Type

t = GetType(System.Data.DataSet)
ser = New System.Xml.Serialization.XmlSerializer(t) '
System.Type.GetType("System.Data.DataSet"))

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

ser.Serialize(ms, xDataSet)
xmlDocument.Load(CType(ms, System.IO.Stream))

End Function



Nov 20 '05 #6

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

Similar topics

1
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...
2
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...
6
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...
3
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,...
5
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...
4
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(...
1
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...
7
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...
11
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....
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
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...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...
0
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...
0
muto222
php
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.