Why use XML to C# instead of JSON to C#?
Choose XML to C# when the source contract is XML and the generated classes need to reflect nested elements, repeated nodes, and document-style structure rather than JSON objects and arrays.
Generate C# DTO classes from XML samples when your .NET service or client still consumes SOAP, partner feeds, or legacy XML responses.
<user>
<id>101</id>
<name>Ada Lovelace</name>
<active>true</active>
<roles>
<role>admin</role>
<role>editor</role>
</roles>
<profile>
<email>ada@example.com</email>
<score>9.8</score>
</profile>
</user>
public class UserModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public bool Active { get; set; }
public List<string> Roles { get; set; } = new();
}
Choose XML to C# when the source contract is XML and the generated classes need to reflect nested elements, repeated nodes, and document-style structure rather than JSON objects and arrays.
Yes. Nested XML elements become child DTO classes, and repeated nodes are inferred into collection fields based on the parsed XML sample.