bcichonski / RestSharp

Simple REST and HTTP API Client for .NET
http://restsharp.org
Apache License 2.0
0 stars 1 forks source link

Xml node with attributes and content at the same time #1

Open bcichonski opened 7 years ago

bcichonski commented 7 years ago

It seems to me that when using default XmlSerializer there is no way to produce xml node that has attribute values and text content at the same time. This was originally found when my team was using RestSharp for communicating with Prestashop 1.6 API, where some nodes should look like:

<language id="1">
 Beer
</language>
bcichonski commented 7 years ago

Questions to consider:

  1. Does it really not possible with default XmlSerializer?
  2. Does it possible using standard DotNetXmlSerializer and if so will it have any impact of best implementation approach?
bcichonski commented 7 years ago

Can be done using DotNetSerializer https://dotnetfiddle.net/pMfHrM - code not working because namespace System.Xml.* is not available.

I think that to achieve maximum consistency it will be best to extend SerializeAs and DeserializeAs attributes with another property Content = true.