Quick question for you guys:

First, let me tell you that I'm new to VB.NET (I've been programming VB6/ASP
for years), so bear that in mind.

I'm working on an application that needs to build XML based on data from a
stored procedure (or procedures, as it may require multiple procedures), and
needs to pass that XML as a string to a Web Service.


Am I better off creating this XML using the XMLDOM that I've used in VB6, or
is there a better/easier way to generate custom XML in VB.NET?


At first I thought I could just dump a DataSet to XML using the WriteXML
method, but at first glance it seems that writes it to a file, and I'd
rather avoid the step of writing to a file, and then having to read it back
into memory again to pass it to the Web Service. Not only that, but the XML
I need to create is rather complex, with elements within elements within
elements, and I've been unable to create the parent/child relationships
between the elements.

Then I thought I could use the XMLTextWriter class, but that too seems to
write only to a file.


Ideas/suggestions?


Thanks!

Re: Building XML in VB.NET by Mary

Mary
Fri Sep 10 12:15:05 CDT 2004

Have you tried the XML functionality in SQL Server? Perhaps your
stored procedures could output it in the correct format? There's an
entire book on XML and Internet support in SQL Books Online.

--Mary

On Fri, 10 Sep 2004 08:15:44 -0400, "Scott Lyon"
<scott.RED.lyon.WHITE@rapistan.BLUE.com> wrote:

>Quick question for you guys:
>
>First, let me tell you that I'm new to VB.NET (I've been programming VB6/ASP
>for years), so bear that in mind.
>
>I'm working on an application that needs to build XML based on data from a
>stored procedure (or procedures, as it may require multiple procedures), and
>needs to pass that XML as a string to a Web Service.
>
>
>Am I better off creating this XML using the XMLDOM that I've used in VB6, or
>is there a better/easier way to generate custom XML in VB.NET?
>
>
>At first I thought I could just dump a DataSet to XML using the WriteXML
>method, but at first glance it seems that writes it to a file, and I'd
>rather avoid the step of writing to a file, and then having to read it back
>into memory again to pass it to the Web Service. Not only that, but the XML
>I need to create is rather complex, with elements within elements within
>elements, and I've been unable to create the parent/child relationships
>between the elements.
>
>Then I thought I could use the XMLTextWriter class, but that too seems to
>write only to a file.
>
>
>Ideas/suggestions?
>
>
>Thanks!
>


Re: Building XML in VB.NET by Jared

Jared
Fri Sep 10 08:04:47 CDT 2004

You can use a stream object to write the xml, you will have to add any
datarelation, constraints, etc. to get the relational structure you want.
Either way, it's probably a stream object that you'll need to research to
produce the results you want. If you are using one of your own webservices
create an "overloaded" method that accepts a dataset or an xmldocument
object - use the messagename attribute.

Dim sw As New System.IO.StringWriter
ds.WriteXml(sw, XmlWriteMode.IgnoreSchema)
sw.Flush()
Dim MyStr As String = sw.ToString
sw.Close()
MyService.MyMethod(myStr)

Jared

"Scott Lyon" <scott.RED.lyon.WHITE@rapistan.BLUE.com> wrote in message
news:Oa56o$ylEHA.712@TK2MSFTNGP09.phx.gbl...
> Quick question for you guys:
>
> First, let me tell you that I'm new to VB.NET (I've been programming
> VB6/ASP
> for years), so bear that in mind.
>
> I'm working on an application that needs to build XML based on data from a
> stored procedure (or procedures, as it may require multiple procedures),
> and
> needs to pass that XML as a string to a Web Service.
>
>
> Am I better off creating this XML using the XMLDOM that I've used in VB6,
> or
> is there a better/easier way to generate custom XML in VB.NET?
>
>
> At first I thought I could just dump a DataSet to XML using the WriteXML
> method, but at first glance it seems that writes it to a file, and I'd
> rather avoid the step of writing to a file, and then having to read it
> back
> into memory again to pass it to the Web Service. Not only that, but the
> XML
> I need to create is rather complex, with elements within elements within
> elements, and I've been unable to create the parent/child relationships
> between the elements.
>
> Then I thought I could use the XMLTextWriter class, but that too seems to
> write only to a file.
>
>
> Ideas/suggestions?
>
>
> Thanks!
>
>



Re: Building XML in VB.NET by Jared

Jared
Fri Sep 10 12:58:11 CDT 2004

You can use a stream object to write the xml, you will have to add any
datarelation, constraints, etc. to get the relational structure you want.
Either way, it's probably a stream object that you'll need to research to
produce the results you want. If you are using one of your own webservices
create an "overloaded" method that accepts a dataset or an xmldocument
object - use the messagename attribute.

Dim sw As New System.IO.StringWriter
ds.WriteXml(sw, XmlWriteMode.IgnoreSchema)
sw.Flush()
Dim MyStr As String = sw.ToString
sw.Close()
MyService.MyMethod(myStr)

Jared

"Scott Lyon" <scott.RED.lyon.WHITE@rapistan.BLUE.com> wrote in message
news:Oa56o$ylEHA.712@TK2MSFTNGP09.phx.gbl...
> Quick question for you guys:
>
> First, let me tell you that I'm new to VB.NET (I've been programming
> VB6/ASP
> for years), so bear that in mind.
>
> I'm working on an application that needs to build XML based on data from a
> stored procedure (or procedures, as it may require multiple procedures),
> and
> needs to pass that XML as a string to a Web Service.
>
>
> Am I better off creating this XML using the XMLDOM that I've used in VB6,
> or
> is there a better/easier way to generate custom XML in VB.NET?
>
>
> At first I thought I could just dump a DataSet to XML using the WriteXML
> method, but at first glance it seems that writes it to a file, and I'd
> rather avoid the step of writing to a file, and then having to read it
> back
> into memory again to pass it to the Web Service. Not only that, but the
> XML
> I need to create is rather complex, with elements within elements within
> elements, and I've been unable to create the parent/child relationships
> between the elements.
>
> Then I thought I could use the XMLTextWriter class, but that too seems to
> write only to a file.
>
>
> Ideas/suggestions?
>
>
> Thanks!
>
>



Re: Building XML in VB.NET by Cor

Cor
Sat Sep 11 02:44:58 CDT 2004

Scott,

The documentation on MSDN is in my opinion a little bit confusing when it
goes about writing a dataset as XML file.

dataset.WriteXML(path) does completly the job.

I hope this helps

Cor