本文介绍了如何序列化这个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

public class Recognition 
{
     public string radio;
     public DateTime date;
     public string file;
     public string listenTime;
     public string intervalTime
}



我做错了什么?


What I'm doing wrong ?

推荐答案

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
  }

}


这篇关于如何序列化这个XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 00:11