c# - Deserialize xlink:href -
c# - Deserialize xlink:href -
i have xml , need deserialize c# object can't figure out how value xlink:href. exception
invalid name character in 'xlink:href'.
but when alter xmlattribute value href or xlink there no value set. how can value xmlserializer?
xml example:
<result xmlns:xlink="http://www.w3.org/1999/xlink"> <items country="nl"> <item name="cube" xlink:href="http://url"/> <item name="square" xlink:href="http://url"/> </items> </result>
c# class:
[xmlroot("result")] public class result { [xmlarray("items")] [xmlarrayitem("item")] public list<item> items { get; set; } } public class item { [xmlattribute("name")] public string name { get; set; } [xmlattribute("xlink:href")] public string url { get; set; } }
deserialize code:
stream response = getresponsefromrequest(requesturl); var serializer = new xmlserializer(typeof(result)); result result = (result)serializer.deserialize(response);
add namespace xmlattribute
attribute:
public class item { [xmlattribute("name")] public string name { get; set; } [xmlattribute("href", namespace="http://www.w3.org/1999/xlink")] public string url { get; set; } }
c# xml
Comments
Post a Comment