PC Review


Reply
Thread Tools Rate Thread

Building XML in VB.NET

 
 
Scott Lyon
Guest
Posts: n/a
 
      10th Sep 2004
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!


 
Reply With Quote
 
 
 
 
Jared
Guest
Posts: n/a
 
      10th Sep 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" <(E-Mail Removed)> wrote in message
news:Oa56o$(E-Mail Removed)...
> 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!
>
>



 
Reply With Quote
 
Mary Chipman
Guest
Posts: n/a
 
      10th Sep 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"
<(E-Mail Removed)> 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!
>


 
Reply With Quote
 
Jared
Guest
Posts: n/a
 
      10th Sep 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" <(E-Mail Removed)> wrote in message
news:Oa56o$(E-Mail Removed)...
> 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!
>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      11th Sep 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MSBuild : Building a project without building it's dependencies ramshankaryadav@gmail.com Microsoft C# .NET 4 8th Dec 2007 05:18 AM
MSBuild : Building a project without building it's dependencies ramshankaryadav@gmail.com Microsoft Dot NET 0 5th Dec 2007 06:29 AM
Automating document building using building blocks and content con =?Utf-8?B?QmlnIERhdmU=?= Microsoft Word Document Management 1 12th Jun 2007 08:01 PM
Building my own PC MikeB Windows XP General 2 20th Jul 2006 07:54 PM
Active Directory and moving from multiple building to a single building drapeau Microsoft Windows 2000 Active Directory 1 10th Sep 2004 06:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:35 PM.