Getting an error when return an XmlElement

M

Maersa

Hi,

I've got a webmethod like the following that returns a XmlElement object but
in some cases I may need to return an "null".

[WebMethod]
public XmlElement myMethod()
{
return null;
}

How would I do this ? Currently IE blows and says the it's not a well
formed XML.

thanks,
 
D

Dan Rogers

Hi Maersa,

When you work with raw XML like this, and then want to display the output
in IE, you have to make sure that the XML you return is valid XML. I'm not
100% sure I understand what you wanted to return, but the XML serializer
will not serialize a class that has a null value. This means that the XML
that is going back in the HTTPGet request has an XML Decl, but no XML body.
This would cause the stylesheet that IE uses to display XML to complain
about not-well-formed XML.

Suggest you may be trying to get an EMPTY element. If that is the case,
you need to return an XML Element class, and have it's value either set to
Null or an empty string.

Hope this helps

Dan Rogers
Microsoft Corporation
--------------------
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top