.Net Represent xml in class without xsd
Ho开发者_如何学编程w would I represent something like this
<product>
<sku>12452</sku>
<attribute name="details">good stuff</attribute>
<attribute name="qty">5</attribute>
</product>
for use in my WCF service? Not sure how to define the multiple attributes whose only difference is the "name".
I need this properly setup as a DataMember so xml gets deserialized into it.
sku would be something like:
[DataMember(Name = "sku")]
public string sku;
What would I use for both of the attributes?
You won't be able to do that using DataContracts, since the DataContract serializer doesn't support XML attributes (only elements). If you really need to generate messages with that schema, you'll have to use XmlSerializer instead.
精彩评论