I use WebService, which return me data of next xml-format:
<CallsToAbonents>
<Property2>99,2</Property2>
<Property1>1,2</Property1>
<Property3>1,2</Property3>
</CallsToAbonents>
Where Property1, Property2 and Property3 is double. I tryed to parse this data by XmlSerializer, which expect, that decimal separator is '.' and parsing failed. I trying to realize IXmlSerializable interface by the next way:
public class CallsToAbonents : IXmlSerializable
{
public CallsToAbonents() { }
public String Name { get; set; }
public double Property1 { get; set; }
public double Property2 { get; set; }
public double Property3 { get; set; }
public CallsToAbonents(string Name, double Property1)
{
this.Name = Name;
this.Property1 = Property1;
}
public System.Xml.Schema.XmlSchema GetSchema() { return null; }
public void ReadXml(System.Xml.XmlReader Reader)
{
/*System.Diagnostics.Debug.WriteLine(Reader.MoveToContent());
System.Diagnostics.Debug.WriteLine(Reader.MoveToContent());*/
while(Reader.Read())
{
System.Diagnostics.Debug.WriteLine("Name={0}; Value={1};", Reader.Name, Reader.Value);
}
}
public void WriteXml(System.Xml.XmlWriter writer)
{
writer.WriteAttributeString("Name", Name);
CultureInfo cultureInfo = CultureInfo.CurrentCulture;
writer.WriteElementString("Property1", this.Property1.ToString(cultureInfo));
writer.WriteElementString("Property2", this.Property2.ToString(cultureInfo));
writer.WriteElementString("Property3", this.Property3.ToString(cultureInfo));
}
}
But in debug window I see next output:
Name=Property2; Value=;
Name=; Value=99,2;
Name=Property2; Value=;
Name=Property1; Value=;
Name=; Value=1,2;
Name=Property1; Value=;
Name=Property3; Value=;
Name=; Value=1,2;
Name=Property3; Value=;
Name=CallsToAbonents; Value=;
I can not understand why? How to get 99.2 as value of Property2?