Jim
Jim

Reputation: 16002

XML Serialize anonymous class

The JSON script serializer (from mvc) can serialize an anonymous class to script. Are there some standard framework (or mvc) classes that can transform an anonymous class to xml?

Currently anonymous classes are not marked as serializable and cannot be converted to xml.

Is there a way to do this without writing reams of code?

Upvotes: 4

Views: 623

Answers (2)

Habdank
Habdank

Reputation: 183

I think that the above did not answer the question directly. Jim did not ask about JSON to XML serializer, but C# anonymous type to XML serializer. This class does not exist out of a box, but can be written easily. Look here: Can I serialize Anonymous Types as xml?

Upvotes: 0

101010
101010

Reputation: 15716

You need reams of code.

But others have already done it for you.

Here's a jQuery plugin (client-side): http://plugins.jquery.com/project/json2xml

Here's some C# code: http://www.phdcc.com/xml2json.htm

Upvotes: 3

Related Questions