Click here to Skip to main content
15,037,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<?xml version="1.0"?>
<Recognition radio="177" date="05/06/2013 17:54:49" file="\\192.168.1.4\mir\radios\\\00177\\20130605\\177_5688051596547880940.mp3" listenTime="60000" intervalTime="62000"/>

Hi, I tried many times with this object
C#
public class Recognition 
{
     public string radio;
     public DateTime date;
     public string file;
     public string listenTime;
     public string intervalTime
}

What I'm doing wrong ?
Posted

1 solution

The bit you're missing is the IXmlSerializable interface. Because your XML is not a standard XML produced by the .Net serialization libraries. You'll require a custom process.

IXmlSerializable Interface[^]

C#
public class Recognition : IXmlSerializable
{

  public string radio;
  public DateTime date;
  public string file;
  public string listenTime;
  public string intervalTime;

  public XmlSchema GetSchema() { return null; }

  public void WriteXml (XmlWriter write) 
  { 
    //write to xml here
  }

  public void ReadXml (XmlReader reader)
  {
    radio = XmlReader.Attributes["radio"];
    //handle other attributes here
  }

}
   
v2
Comments
Jeankininho 6-Jun-13 7:28am
   
Thanks Work it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900