--------------------------------------------------------------------------------
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