473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

streamwriter xml doesn't parse until resaved in notepad

Hello got a bit of wierd one, and i think its probably to do with encoding

i have inherited a application that should write some xml for a domdoc application, the output looks valid but IE insists the top level element (noteTypeAbbrv) is not valid. if i tke the file ans resave with no changes in notepad then the file parses fine if the domdoc app and ie...

anybody got any ideas

thanks

Mark


Sub XMLFiles(ByVal StateId As Integer, ByVal noteTypeAbbrv As String)
Dim ds As DataSet = SqlHelper.ExecuteDataset(connStr, CommandType.StoredProcedure, "spGetStateNotesXML", New SqlParameter("@stateID", StateId), New SqlParameter("@NoteTypeAbbrv", noteTypeAbbrv))
If ds.Tables(0).Rows.Count > 0 Then
Dim dt As DataTable = ds.Tables(0)
Dim str As New StringBuilder
Dim col As DataColumn
Dim row As DataRow
Dim i As Integer = 0
str.Append("<?xml version=""1.0"" standalone=""yes""?>")
str.AppendLine()
str.Append("<" & noteTypeAbbrv & ">")
If dt.Rows.Count <= 1 Then
str.AppendLine()
str.Append("<" & dt.TableName.ToString() & ">")
str.AppendLine()
For Each col In dt.Columns
str.Append("<" & col.ColumnName.ToString & ">")
For Each row In dt.Rows
str.Append(row.Item(col.ColumnName))
Next
str.Append("</" & col.ColumnName.ToString & ">")
str.AppendLine()
Next
str.Append("</" & dt.TableName.ToString() & ">")
Else
For Each row In dt.Rows
str.AppendLine()
str.Append("<" & dt.TableName.ToString() & " id=""id" & row.Item("NoteLookUpID") & """>")
str.AppendLine()
For Each col In dt.Columns
str.Append("<" & col.ColumnName.ToString & ">")
str.Append(row.Item(col.ColumnName))
str.Append("</" & col.ColumnName.ToString & ">")
str.AppendLine()
Next
i = i + 1
str.Append("</" & dt.TableName.ToString() & ">")
Next
End If
str.AppendLine()
str.Append("</" & noteTypeAbbrv & ">")
Dim objStreamWriter As StreamWriter
Dim filename As String = "c:\iauapp\iau_" & noteTypeAbbrv & ".xml"
objStreamWriter = File.CreateText(filename)
objStreamWriter.WriteLine(str.ToString)
'Close the stream
objStreamWriter.Close()
'Dim msg As String = "The XML File has been successfully created on your pc at the following location:" & filename
End If
Jan 3 '07 #1
0 911

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: | last post by:
Hi, When constructing StreamWriter with the following.. FileStream f = new FileStream(..); StreamWriter s = new StreamWriter(f); Then attempt to write out هنِ letters they become garbage. ...
5
by: Brendan Miller | last post by:
Hi, I have been having a problem writing the contents of a dataset to a .csv file. When I write to a .csv file and open it with either Excel or Wordpad the "french" characters are wrong. When I...
12
by: Nina | last post by:
Hi there, What is the maximum length that one line can hold in a text file using StreamWriter's Write or WriteLine method? If the string is too long for one line to hold, what will Write or...
0
by: markofsoton | last post by:
-------------------------------------------------------------------------------- Hello got a bit of wierd one, and i think its probably to do with encoding i have inherited a application that...
24
by: =?Utf-8?B?RHVja3dvbg==?= | last post by:
Hello, My code is suppose to write to an existing file. But after my C# code appends the file, the previous text loses all the endline characters, becoming one long line. How can I retain the...
5
by: Rob | last post by:
Hi, I have a VB.Net application that parses an HTML file. This file was an MS Word document that was saved as web page. My application removes all unnecessary code generated by MS Word and does...
2
by: Eric | last post by:
Hi, i'm experientating with object StreamWriter in asp.net. This code works: the string is written to an excel sheet, but i have a questions about it: how does asp.net know the string must be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.