![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
|
I have a webservice in which I dump XML into a string and return it. The only problem is that it has the < and in it. How can I return bonafide XML? WebMethod> Public Function GetResults(ElectionDate as datetime) As string Dim CN As SqlConnection = New SqlConnection(sConnection) CN.Open() Dim CMD As SqlCommand = New SqlCommand() CMD.CommandText = "lp_ElectionResultsForXML" CMD.CommandType = CommandType.StoredProcedure CMD.CommandTimeout = 15 CMD.Connection = CN CMD.Parameters.Add("@ElectionDate", System.Data.SqlDbType.SmallDateTime).Value = ElectionDate Dim reader As XmlReader = CMD.ExecuteXmlReader() Dim ds As DataSet = New DataSet() ds.ReadXml(reader, XmlReadMode.Fragment) Dim doc As XmlDataDocument = New XmlDataDocument(ds) strXML = doc.innerxml strXML = strxml.Replace("<Schema1>","<ElectionResults " & "LastUpdate=""" & datetime.Now() & """>") strXML = strXML.Replace("</Schema1>","</ElectionResults>") CN.Close() Return strXML You see the cheap way I put an attribute in this. The stored procedure uses FOR XML EXPLICIT, ELEMENT and I can't figure a better way! |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |