0

Can anyone recommend a .Net XML Serialization library (ideally open source).

I am looking for a robust XML serialization library that I can throw any object at, which will produce a human readable XML representation of the public properties for logging purposes.

  • I never need to be able to deserialize.
  • XmlSerializer's requirement of an object having a parameter constructor is too restrictive for what I want.
  • DataContractSerializer does not give enough control over the output (which is not particularly human-readable).

Any recommendations appreciated!

Thanks

James
  • 7,877
  • 7
  • 42
  • 57
  • Does this mean you want to be able to throw objects at it that are otherwise not serializable using the built-in serializer. Ex. Objects that are not attributed with the SerializableAttribute, do not have parameterless contructors, setters, etc...? – JoeGeeky May 18 '10 at 18:44
  • For human-readability ... are you willing to consider JSON serialization? I find it much easier in general. – overslacked May 18 '10 at 19:31
  • JoeGeeky - yes, I would like to serialize objects that are otherwise not serializable using XMLSerializer. - Overslacked - the reason i would like to stick with XML is that this makes it easy to further manipulate the XML using built in .Net XML handling code - which I want to take advantage of. – James May 18 '10 at 19:54

3 Answers3

5

2 that come to mind right away:

http://xsd2code.codeplex.com/

http://www.codeproject.com/KB/XML/yaxlib.aspx

code4life
  • 15,655
  • 7
  • 50
  • 82
2

It turned out that YaxLib has some of the same issue I was having with the XMLSerializer (it needs a parameterless constructor, and I had some issues with stack-overflow exceptions due to recursion).

In the end I went with json serialization using a library called json.net. I have been seriously impressed with this, and so far is has seemed way way more robust than any xml library i have tried, and very flexible too. The code is open source, and very impressive too. Kudos James Newton-King (the guy who wrote it). http://james.newtonking.com/projects/json-net.aspx

James
  • 7,877
  • 7
  • 42
  • 57
0

You could transform the XML using XLST.