472,354 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 10057
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....
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

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.