开发者

.Net Represent xml in class without xsd

开发者 https://www.devze.com 2022-12-18 12:30 出处:网络
Ho开发者_如何学编程w would I represent something like this <product> <sku>12452</sku>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消