By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,742 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,742 IT Pros & Developers. It's quick & easy.

converting .xml to a comma delimited text file

P: n/a
Is there a way to convert or copy a .xml file to a comma delimited text file
using vb .net?

Thanks for any help.

Bernie Yaeger
Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hi Bernie,

A document or an dataset?

Cor
Is there a way to convert or copy a .xml file to a comma delimited text file using vb .net?

Nov 20 '05 #2

P: n/a

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Is there a way to convert or copy a .xml file to a comma delimited text file using vb .net?


That's an extremely vague question. Could you provide more detail,
specifically what the XML currently looks like and what you want the CSV to
look like?
Nov 20 '05 #3

P: n/a
>
That's an extremely vague question. Could you provide more detail,
specifically what the XML currently looks like and what you want the CSV to look like?

Is that a question Jeff, when you have a XMLdocument you have to use the
xmlReader and when it is a dataset you can use the readXML.

That is the only important point in my opinion.
For the last one I have a simple generic sample.

By the way Bernie is a very regular to this dotNet newsgroup he helps often.

Cor
Nov 20 '05 #4

P: n/a
Hi Jeff,

Tx for your reply.

I am trying to take a table within a dataset and get it into a comma
delimited .txt file. If I try to do this with a stream or textstream using,
say, a 25000 row table, it takes quite some time. If I use the writexml
method, it's incredibly fast. So I thought - what if I first write it to
xml and then convert it? Ultimately, what I need is a comma delimited
textfile (.txt). Doing the same thing in .csv using interop and the Excel
object, it also takes far too long.

Thanks for any help.

Bernie

"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Is there a way to convert or copy a .xml file to a comma delimited text file
using vb .net?


That's an extremely vague question. Could you provide more detail,
specifically what the XML currently looks like and what you want the CSV

to look like?

Nov 20 '05 #5

P: n/a
Hi Cor,

Nice to hear from you again.

The answer is a document, but let me explain more thoroughly.

I am trying to take a table within a dataset and get it into a comma
delimited .txt file. If I try to do this with a stream or textstream using,
say, a 25000 row table, it takes quite some time. If I use the writexml
method, it's incredibly fast. So I thought - what if I first write it to
xml and then convert it? Ultimately, what I need is a comma delimited
textfile (.txt). Doing the same thing in .csv using interop and the Excel
object, it also takes far too long.

Thanks for any help.

Bernie
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Bernie,

A document or an dataset?

Cor
Is there a way to convert or copy a .xml file to a comma delimited text

file
using vb .net?


Nov 20 '05 #6

P: n/a
What about using XSLT on the xml that you have? I know XSL is notoriously
slow, but it still be a lot faster then just writing it and formatting it
manually.

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi Cor,

Nice to hear from you again.

The answer is a document, but let me explain more thoroughly.

I am trying to take a table within a dataset and get it into a comma
delimited .txt file. If I try to do this with a stream or textstream using, say, a 25000 row table, it takes quite some time. If I use the writexml
method, it's incredibly fast. So I thought - what if I first write it to
xml and then convert it? Ultimately, what I need is a comma delimited
textfile (.txt). Doing the same thing in .csv using interop and the Excel
object, it also takes far too long.

Thanks for any help.

Bernie
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Bernie,

A document or an dataset?

Cor
Is there a way to convert or copy a .xml file to a comma delimited
text file
using vb .net?



Nov 20 '05 #7

P: n/a
Hi Marina,

Tx for your response. I'll try it.

Tx again,

Bernie

"Marina" <so*****@nospam.com> wrote in message
news:O3****************@TK2MSFTNGP10.phx.gbl...
What about using XSLT on the xml that you have? I know XSL is notoriously
slow, but it still be a lot faster then just writing it and formatting it
manually.

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi Cor,

Nice to hear from you again.

The answer is a document, but let me explain more thoroughly.

I am trying to take a table within a dataset and get it into a comma
delimited .txt file. If I try to do this with a stream or textstream

using,
say, a 25000 row table, it takes quite some time. If I use the writexml
method, it's incredibly fast. So I thought - what if I first write it to
xml and then convert it? Ultimately, what I need is a comma delimited
textfile (.txt). Doing the same thing in .csv using interop and the Excel object, it also takes far too long.

Thanks for any help.

Bernie
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Bernie,

A document or an dataset?

Cor

> Is there a way to convert or copy a .xml file to a comma delimited

text file
> using vb .net?
>



Nov 20 '05 #8

P: n/a
Hi Bernie,

Now I do not understand it anymore, you want to write a table and than read
it

Here is my sample. See what you can do with it.
\\\\
Dim sw As New IO.StreamWriter("C:\Bernie.csv")
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
Dim row As New System.Text.StringBuilder
row.Append("""")
For y As Integer = 0 To ds.Tables(0).Columns.Count - 1
row.Append(ds.Tables(0).Rows(i)(y).tostring)
If y <> ds.Tables(0).Columns.Count - 1 Then
row.Append(""",""")
' if you want it with a tab
' row.Append("""")
' row.Append(chr(09))
' row.Append("""")
Else
row.Append("""")
End If
Next
sw.WriteLine(row.ToString)
Next
sw.Flush()
sw.Close()
///
Nov 20 '05 #9

P: n/a
Hi Cor,

Thanks for the sample - I'll give it a try!

Bernie
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Or*************@TK2MSFTNGP11.phx.gbl...
Hi Bernie,

Now I do not understand it anymore, you want to write a table and than read it

Here is my sample. See what you can do with it.
\\\\
Dim sw As New IO.StreamWriter("C:\Bernie.csv")
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
Dim row As New System.Text.StringBuilder
row.Append("""")
For y As Integer = 0 To ds.Tables(0).Columns.Count - 1
row.Append(ds.Tables(0).Rows(i)(y).tostring)
If y <> ds.Tables(0).Columns.Count - 1 Then
row.Append(""",""")
' if you want it with a tab
' row.Append("""")
' row.Append(chr(09))
' row.Append("""")
Else
row.Append("""")
End If
Next
sw.WriteLine(row.ToString)
Next
sw.Flush()
sw.Close()
///

Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.