I have an XML that is not well formatted but needs to be consumed:
<Users>
<User First="aaa" Second="bbb">InnerValue</User>
<User First="bbb" Second="">InnerValue</User>
</Users>
Clases definitions:
public class Users
{
public List<User> User{ get; set; }
}
public class User
{
[JsonProperty("@First")]
public string First{ get; set; }
[JsonProperty("@Second")]
public string Second{ get; set; }
//how to define a property to get the InnerValue
}
To parse:
XDocument xmlDocument = XDocument.Parse(xmlData);
string jsonData = JsonConvert.SerializeXNode(xmlDocument);
Users users = JsonConvert.DeserializeObject<Users>(jsonData);
So everything is nicely deserialized but how to get the inner value?