Returning a XML from webservice

R

Ronchese

Helllo.

I need to return a XML from my WebService, but I'm not getting the result as
a XML. I mean, instead of receiveing a tag (<xyy></xyz>), I'm receiving it
encoded (with &lt; or &gt;).

There is some right way to return the correct XML from my WebService?


Just for example, the WebMethod looks like it:

<WebMethod()> _
Public Function GetSomeXml(ID as Integer) As String
'the code builds a XML string from a Xml.XmlDocument object
'...
'...
End Function
 
J

John Timney \(MVP\)

Your actually returning a string - not XML, it will be encoded as a strings
are.

Try returning an XML document instead

[WebMethod]
public XmlDocument GetSomeXml(ID as Integer){
XmlDocument myDom = new XmlDocument();
// load some XML ...
return myDom;
}

Return this into an xmlNode and it wont be encoded and you can navigate it
with XPath and convert it to an unecoded string if you wish

localhost.Service1 proxy = new localhost.Service1();
XmlNode xml = proxy.GetSomeXml(22);

--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top