xml字符串dserialization或数据集 [英] xml string dserialization or dataset

查看:42
本文介绍了xml字符串dserialization或数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在执行一个返回xml字符串的函数。我很困惑使用反序列化或DataSet,还有一件事我在其中一个xml字符串中返回了元素。

i'm executing a function that return xml string. i'm confused either to use deserialization or DataSet, one more thing i have array of elements in one of the xml string returned.

 

还有一件事我一直在玩反序列化而不是xml字符串但由于某些原因我无法反序列化xml中的元素数组

one more thing i've been playing around with the deserialization but of the xml string but for some reason i can't deserialization the array of elements from the xml

 

单个元素可以正常工作

 

我创建了三个类包络头,包络属性和包围身体然后我创建了另一个类,它结合了所有以前的类并将包络体定义为数组但不幸的是我总是在包络体中获得0个元素

i have created three classes envelop header, envelop properties, and envelop body then i'm created another class that combine all previous classes and defined the envelop body as array but unfortunately i always get 0 elements in the envelop body

 

这是我xml的结构

 

< doc>

  ; < doc_HEADER>

    < DATE_TIME> 20100630122737< / DATE_TIME>

  < / doc_HEADER>

  < Property_HEADER>

    < size> 0< / size>

    < allowedit>< / allowedit>

    < numberofsection> 3< / numberofsection>

  < / Property_HEADER>

  < section>

    < code> 1< / code>

    < id> 789< / id>>

  < / section>

  < section>

    < code> 2< / code>

    < id>> 456< / id>>

  < / section>

    < section>

    < SEG_NO> 3< / code>

    < id>> 123< / id>>

  < / section>

< / doc>

<doc>
  <doc_HEADER>
    <DATE_TIME>20100630122737</DATE_TIME>
  </doc_HEADER>
  <Property_HEADER>
    <size>0</size>
    <allowedit></allowedit>
    <numberofsection>3</numberofsection>
  </Property_HEADER>
  <section>
    <code>1</code>
    <id>789</id>>
  </section>
  <section>
    <code>2</code>
    <id>>456</id>>
  </section>
    <section>
    <SEG_NO>3</code>
    <id>>123</id>>
  </section>
</doc>

推荐答案

您的样本格式不正确。如果你有一个结构良好的样本,你可以使用
xsd.exe命令行工具从该示例推断出架构,然后您可以再次使用xsd.exe工具从架构中创建C#或VB.NET类。这些类可以与
XmlSerializer一起使用。
Your sample is not well-formed. If you have a well-formed sample you can use the xsd.exe command line tool to infer a schema from that sample, then you can use the xsd.exe tool again to create C# or VB.NET classes from the schema. Those classes can then be used with XmlSerializer.


这篇关于xml字符串dserialization或数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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