TheWizardofInt
Junior Contributor
Code:
<WebMethod()> Public Function GetUsers() As XmlDocument
Dim xmlDoc As New XmlDocument
Dim s As New System.Text.StringBuilder
Dim sPath As String
Dim sw As IO.StreamWriter
...
With s
.Append("<?xml version=" & """" & "1.0" & """" & "?>" & vbCrLf)
.Append("<Users>" & vbCrLf)
If Not dt Is Nothing Then
For i = 0 To dt.Rows.Count - 1
'here we create the entries for all files
.Append("<UserName>" & dt.Rows(i).Item(0) & "</UserName>" & vbCrLf)
Next
End If
.Append("</Users>" & vbCrLf)
End With
sPath = Server.MapPath("./documents") & "\fhdytxuu.xml"
sw = New System.IO.StreamWriter(sPath, False)
sw.Write(s)
sw.Flush()
sw.Close()
sw = Nothing
xmlDoc.Load(sPath)
IO.File.Delete(sPath)
Return xmlDoc
In a nutshell, I use a stringbuilder to build an xml document (which works), I load the XMLDocument (which works), and provide it from the webservice as an XMLDocument
Whatever program reads it, reads it as a node. This is not good, because the people who read it need to read an XML document
Am I using the wrong method here, or leaving a step out to allow my end user to read the document?