Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an XmlEncode / XmlDecode for .NET?

Are there methods for encoding and decoding XML in .NET? I can't seem to find them and am wondering why they aren't there and what to use instead?

I need to encode an XML document and pass it through to a string parameter on a web service. It then needs to be decoded at the other end.

like image 722
Alex Angas Avatar asked Apr 08 '10 01:04

Alex Angas


2 Answers

Actually with the nice objects in System.Xml.Linq you need not worry.

What I mean is you will not get a runtime exception if you run this code.

var element = new XElement("Name", "<Node />");

The value of the element will be a text node with &lt;Node /&gt;.

like image 53
ChaosPandion Avatar answered Sep 16 '22 19:09

ChaosPandion


If you are referring to encoding/decoding of XML names, there is XmlConvert.EncodeName and DecodeName.

Or are you talking about specifying the encoding/decoding of the whole XML document using XmlDeclaration or XDeclaration? (I thought this took care of encoding for us)

like image 38
si618 Avatar answered Sep 19 '22 19:09

si618