HighTechTalks DotNet Forums  

Re: Return XML From Webservice

ASP.net Web Services microsoft.public.dotnet.framework.aspnet.webservices


Discuss Re: Return XML From Webservice in the ASP.net Web Services forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Dino Chiesa [MSFT]
 
Posts: n/a

Default Re: Return XML From Webservice - 07-08-2003 , 11:25 PM






return an XmlNode

"Dave" <davet65109 (AT) hotmail (DOT) com> wrote

Quote:
I have a webservice in which I dump XML into a string and
return it. The only problem is that it has the &lt; 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!




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.