Can anyone recommend a .Net XML Serialization libr

2019-08-06 01:15发布

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

3条回答
Deceive 欺骗
2楼-- · 2019-08-06 01:38

You could transform the XML using XLST.

查看更多
爷的心禁止访问
4楼-- · 2019-08-06 01:47

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

查看更多
登录 后发表回答