网上 XML序列化的例子中一般都是属性作为元素节点的较多

类似于以下形式的纵向的排列,

 

    <book>
        <title>The Confidence Man</title>
        <author>
            <first-name>Herman</first-name>
            <last-name>Melville</last-name>
        </author>
        <price>11.99</price>
    </book>

 

今天正好找到MS的例子,带横向内嵌属性的。

 

<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2"/>

 

初次接触的朋友们注意了,手工编写代码或者使用XSD工具自动生成代码时,

区别就在于

使用XmlElementAttribute类时候,被标记的属性会生成结点

使用XmlAttributeAttribute类时候,被标记的属性会内嵌,不生成新的结点

 

以下是微软的连接,内容不错可以直接参考:)

http://msdn.microsoft.com/zh-cn/library/system.xml.schema.xmlschemainfo.schemaelement.aspx

相关文章:

  • 2021-11-25
  • 2021-08-04
  • 2021-11-16
  • 2022-03-02
猜你喜欢
  • 2021-06-18
  • 2021-10-16
  • 2021-06-02
相关资源
相似解决方案