如何正确实现ReadXML()方法? [英] How to implement correctly ReadXML() method?

查看:577
本文介绍了如何正确实现ReadXML()方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我必须请求你帮助XML序列化。



我必须反序列化这个XML文档(一张电子发票):



 <   ElectronicInvoice  >  
< 标头 >
< 传输 >
< Id < span class =code-keyword>>
< IdCountry > IT < / IdCountry < span class =code-keyword>>
< VatNumber > 12345689 < / VatNumber >
< / Id >
< 代码 > 123456 < /代码 >
< TransmissionFormat > ABC < / TransmissionFormat >
< 联系人 >
< 电话 > 05512345 < /电话 >
< 电子邮件 > foo@mail.com < /电子邮件 >
< / Contacts >
< /传输 >
< /标题 >
< / ElectronicInvoice >





我尝试使用XMLSerializer反序列化,因此ElectronicInvoice中的每个类都必须实现IXMLSerializer接口。

如何实现ReadXML()方法?



对不起我的英文。提前谢谢。

解决方案

在这里,您可以在CP网站上找到几篇关于XML序列化和反序列化的文章。请使用 SearchBox [< a href =http://www.codeproject.com/search.aspx?q=xml+serialization+deserialization&doctypeid=1%3b2%3b3%3b13%3b14\"target =_ blanktitle =New Window> ^ 在本网站的右上角,例如:自定义类集合序列化和反序列化的完整示例 [ ^ ]


Hi guys! I have to ask you help for XML serialization.

I have to deserialize this XML document (a piece of electronic invoice):

<ElectronicInvoice>
  <Header>
    <Transmission>
      <Id>
        <IdCountry>IT</IdCountry>
        <VatNumber>12345689</VatNumber>
      </Id>
      <Code>123456</Code>
      <TransmissionFormat>ABC</TransmissionFormat>
      <Contacts>
        <Phone>05512345</Phone>
        <Email>foo@mail.com</Email>
      </Contacts>
    </Transmission>
  </Header>
</ElectronicInvoice>



I try to deserialize with XMLSerializer, so each class in ElectronicInvoice has to implement IXMLSerializer interface.
How can I implement the ReadXML() method?

Sorry for my english. Thank you in advance.

解决方案

Here, on CP site, you'll find several articles about serialization and deserialization of XML. Please, use SearchBox[^] on the right-top corner of this site, for example: A Complete Sample of Custom Class Collection Serialization and Deserialization[^]


这篇关于如何正确实现ReadXML()方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆