EDN Admin
Well-known member
following is my code XmlTextReader reader=new XmlTextReader(@"D:dealer.xml"); reader.WhitespaceHandling = WhitespaceHandling.None; XmlRootAttribute xRoot = new XmlRootAttribute(); xRoot.ElementName = "STOCKISTS"; // xRoot.Namespace = "http://www.cpandl.com";
xRoot.IsNullable = true; XmlSerializer serializer = new XmlSerializer(typeof(STOCKISTS),xRoot); STOCKISTS result; result = (STOCKISTS)serializer.Deserialize(reader); my class [XmlRoot(Namespace = @"http://www.w3.org/2001/xml", ElementName = "STOCKISTS")] public
class STOCKISTS { [XmlElement(ElementName = "STOCKIST", IsNullable = false)] public STOCKIST[] dealers; } public class STOCKIST { [XmlElement(ElementName = "URN")] public string Uid; [XmlElement(ElementName = "NAME")] public string Name; [XmlElement(ElementName
= "ADDRESS")] public string Address; [XmlElement(ElementName = "SUBURB")] public string SUBURB; -- my xml file <?xml version="1.0" encoding="utf-8" ?> - <STOCKISTS> - <STOCKIST> <URN>2300432</URN> <NAME>Niddrie Carpet Choice</NAME>
<address>400 Keilor Road</address>
<SUBURB>NIDDRIE</SUBURB> <STATE>VIC</STATE> <POSTCODE>3042</POSTCODE> <PHONE>03 9379 2900</PHONE> <FAX>03 9351 0227</FAX> <EMAIL>niddrie@carpetchoice.com.au</EMAIL> <ISMASTER>True</ISMASTER> </STOCKIST> I donno what went i am unable to deserialize this, Every
time my result is null, I am unable to figure out what went wrong. any help highly appreciated and needed. Thanks, Swathi
View the full article
xRoot.IsNullable = true; XmlSerializer serializer = new XmlSerializer(typeof(STOCKISTS),xRoot); STOCKISTS result; result = (STOCKISTS)serializer.Deserialize(reader); my class [XmlRoot(Namespace = @"http://www.w3.org/2001/xml", ElementName = "STOCKISTS")] public
class STOCKISTS { [XmlElement(ElementName = "STOCKIST", IsNullable = false)] public STOCKIST[] dealers; } public class STOCKIST { [XmlElement(ElementName = "URN")] public string Uid; [XmlElement(ElementName = "NAME")] public string Name; [XmlElement(ElementName
= "ADDRESS")] public string Address; [XmlElement(ElementName = "SUBURB")] public string SUBURB; -- my xml file <?xml version="1.0" encoding="utf-8" ?> - <STOCKISTS> - <STOCKIST> <URN>2300432</URN> <NAME>Niddrie Carpet Choice</NAME>
<address>400 Keilor Road</address>
<SUBURB>NIDDRIE</SUBURB> <STATE>VIC</STATE> <POSTCODE>3042</POSTCODE> <PHONE>03 9379 2900</PHONE> <FAX>03 9351 0227</FAX> <EMAIL>niddrie@carpetchoice.com.au</EMAIL> <ISMASTER>True</ISMASTER> </STOCKIST> I donno what went i am unable to deserialize this, Every
time my result is null, I am unable to figure out what went wrong. any help highly appreciated and needed. Thanks, Swathi
View the full article