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

Beginner needs help

P: n/a
I'm a beginner in XML language and I'm trying to create an XML file 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
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.

Toni Sevastjanoff

Mar 22 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.