XML Writer/Excel question

J

JT

Hello,


I'm a beginner in XML language and I'm trying to create an XML file from
Access tables (more than 2 tables, lot of computation for values shown in
the following table, values are averages of many other values) that could be
viewed in Excel as a table that has rows and columns like this:

Q1 Q2
Row1 3 5
Row2 4 1
Row3 2 3

I use Visual Studio 2005, and ASP.NET.

But my table ends up like this: When I write to another column, the program
continues writing from the next row instead of returning to Row1.

attribuutit /Q19 /Q20 /Q21
Row1
Row2
Row3
Row4
10
12
14
15
10
12
14
15
10
12
14
15




----------------
The code I use is like this:

Dim enc As Encoding
Dim objXMLTW As New XmlTextWriter("c:\officet\testi2.xml", enc)

Dim r1 As DataRow, r2 As DataRow, r0 As DataRow

---- the first column -----
objXMLTW.WriteStartElement("attribuutit")

For Each r0 In datasetAttribuutti.Tables("ATTRIBUUTTI").Rows

objXMLTW.WriteElementString("attribuutit", r0.Item("NIMI"))

Next

objXMLTW.WriteEndElement()


---- columns after that, using loops ----

For Each r1 In datasetOsaalueet.Tables("OSAALUEET").Rows

For Each r2 In datasetKysymykset.Tables("KYSYMYKSET").Rows

If r1.Item("OSAALUENUMERO") = r2.Item("OSAALUENUMERO") Then

objXMLTW.WriteStartElement("Q" & r2.Item("KYSYMYSNUMERO"))

For Each r0 In dsAttribuutti.Tables("ATTRIBUUTTI").Rows

value = .....

objXMLTW.WriteElementString("Q" & r2.Item("KYSYMYSNUMERO"),
value)

Next

objXMLTW.WriteEndElement()

End If

Next

Next

This is probably a very amateurish question, but I hope someone could help
me with this, anyway. Thanks in advance.

Jarkko
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top