c# - Using XmlSerializer and setting root class name -
trying work xmlserializer nicely deserialize stuff webservice.
here class declaration:
[serializable] public class carrierlookupresponse { [xmlelement(elementname = "responsedo")] public responsedo responsedo { get; set; } }
here how xml looks:
<?xml version="1.0" encoding="utf-8" ?> <carrierservice.carrierlookup> <responsedo> <status>approved</status> <action>ok</action> <code>sfw00389</code> <displaymsg></displaymsg> <techmsg></techmsg> </responsedo>
here code use deserialize:
var serializer = new xmlserializer(typeof(carrierlookupresponse)); var carrierlookupresponse = serializer.deserialize(new stringreader(response.key)) carrierlookupresponse;
problem simple. service returns "carrierservice.carrierlookup" , need force deserialize "carrierlookupresponse"
i can't put xmlelement attribute on class itself, have no idea how map name properly.
have tried xmlroot attribute?
[serializable] [xmlroot("carrierservice.carrierlookup")] public class carrierlookupresponse { ...
Comments
Post a Comment