开发者

.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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜