网站源码下载PR查询短网址
首页编程数据库网页图形冲浪邮件下载浏览器QQ系统办公软件站长安全手机邮件认证组网通信


网站首页 -> 网络编程 -> xml教程
XML Serialization Introduction

发表日期:2009-10-28



Serialization is the PRocess of converting an object into a form that can be readily transported. For example, you can serialize an object and transport it over the Internet using HTTP between a client and a server. On the other end, deserialization reconstructs the object from the stream.
XML serialization serializes only the public fields and property values of an object into an XML stream. XML serialization does not include type information. For example, if you have a Book object that exists in the Library namespace, there is no guarantee that it will be deserialized into an object of the same type.

Note   XML serialization does not convert methods, indexers, private fields, or read-only properties (except read-only collections). To serialize all an object's fields and properties, both public and private, use the BinaryFormatter instead of XML serialization.
The central class in XML serialization is the XmlSerializer class, and its most important methods are the Serialize and Deserialize methods. The XML stream generated by the XmlSerializer is compliant with the World Wide Web Consortium (www.w3.org) XML Schema definition language (XSD) 1.0 recommendation. Furthermore, the data types generated are compliant with the document titled "XML Schema Part 2: Datatypes."

The data in your objects is described using programming language constructs like classes, fields, properties, primitive types, arrays, and even embedded XML in the form of XmlElement or XmlAttribute objects. You have the option of creating your own classes, annotated with attributes, or using the XML Schema Definition tool to generate the classes based on an existing XML Schema.

If you have an XML Schema, you can run the XML Schema Definition tool to produce a set of classes that are strongly typed to the schema and annotated with attributes. When an instance of such a class is serialized, the generated XML adheres to the XML Schema. Provided with such a class, you can program against an easily manipulated object model while being assured that the generated XML conforms to the XML schema. This is an alternative to using other classes in the .NET Framework, such as the XmlReader and XmlWriter classes, to parse and write an XML stream. Those classes allow you to parse any XML stream. In contrast, use the XmlSerializer when the XML stream is expected to conform to a known XML Schema.

Attributes control the XML stream generated by the XmlSerializer class, allowing you to set the XML namespace, element name, attribute name, and so on, of the XML stream.

The XmlSerializer class can further serialize an object and generate an encoded SOAP XML stream. The generated XML adheres to section 5 of the World Wide Web Consortium document titled "Simple Object access Protocol (SOAP) 1.1.".

The XmlSerializer class generates the SOAP messages created by, and passed to, XML Web services. To control the SOAP messages, you can apply attributes to the classes, return values, parameters, and fields found in an XML Web service file (.asmx). You can use both the attributes listed in "Attributes That Control XML Serialization" and "Attributes That Control Encoded SOAP Serialization" because an XML Web service can use either the literal or encoded SOAP style.


上一篇:XML教程:什么是XML及XML和HTML的区别 人气:31468
网站文章搜索
邮件订阅服务
输入你的邮件地址,你将不会错过任何关于<xml教程教程>的内容
今日更新文章
·PS打造清爽艳丽的海景婚片
·Photoshop打造漂亮的黄绿色非主流MM
·PS调出MM秀丽清爽的色彩
·Photoshop打造洁白如玉的完美肌肤
·Photoshop给MM打造一幅光环艺术照
·Photoshop制作个性青黄色非主流效果
·PS给人物照片添加艺术背景
·Photoshop打造柔美的紫黄色时装美女图片
·Photoshop加强人像图片的质感并增加梦幻
·怎样让新站从开始就拥有高权重
·SEO市场的高端盈利模式详细分解
·站内高质量原创文章有利于网站优化
本栏目推荐文章
·用缓冲技术提高JSP应用的性能和稳定性
·利用ThreadLocal记录日志
·基本图象处理代码(3)
·Java的数据库连接
·c++面向对象的编程入门篇--类构造函数与
·利弊分析——浅析开源的现实作用
·数据结构算法集---C++语言实现
·[视频教程]曹鹏 PHP MYSQL开发(17) - 条
·轻型数据库SQLite结合PHP的开发
·Android客户端软件开发_16、下载模块的下
·神话与谬误:争论C++前你应当知道什么
·为查询结果建立向后/向前按钮
Copyright © 2005-2012 www.Devdao.com All rights reserved | 沪ICP备05001343号 sitemap