xml是如何工作的,并且用于存储数据或传输数据? [英] how does xml works and is it used to store data or transfer data?

查看:80
本文介绍了xml是如何工作的,并且用于存储数据或传输数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对xml非常困惑.我不知道它是如何工作的.它以Xml格式存储数据还是存储在数据库中.还是用来在机器之间传输数据?客户端是否必须传输xml文件,服务器是否读取文件或客户端以xml格式传递数据和服务器存储.

i am very confuse with the xml. i dont know how it works. does it store data in Xml format or store in database. or it is used of transfer data between machine? does client have to tranfer xml file and server read that file or client passes data and server store in xml format.

推荐答案

您可以将XML用于存储和存储XML.传输数据.
对于传输,通常不创建文件并传输,而是直接发送内容.

XML是人类可读的文本.一些字符(<"和>")被解释为关键字标记.这样,它在用途上就非常灵活.


要将数据从发送方计算机传输到接收方计算机,您很可能会将要传输的数据存储在一个对象中.

发送者序列化对象.这意味着它将对象转换为字节流.可以使用XML,SOAP(基于XML构建),JSON等格式格式化此流.

接收器接收字节流并将其反序列化为一个对象.该对象应该与发送者之前发送过的对象相等,因为它保存相同的数据.

(反序列化)部分可能会变得很奇怪.因此,请尝试使用已经起作用的东西.在C#中,我使用了 SOAP格式化程序类 [ ^ ],效果很好.您应该寻找两个端点都存在的东西.
[/EDIT]
You can use XML is for both, storing and transferring data.
For transferring, you usually don''t create a file and transfer it but send the content directly.

XML is human readable text. Some of the characters (''<'' and ''>'') are interpreted as keyword markers. That way it is very flexible in what you can use it for.


For transferring data from a sender machine to a receiver machine, you would most likely have the data you want to transfer in an object.

The sender serializes the object. That means it converts the object to a byte stream. This stream can be formatted in XML, SOAP (which is built on top of XML), JSON, whatever.

The receiver receives the byte stream and deserializes it to an object. This object should be equivalent to the one the sender has sent before in that it holds the same data.

The (de)serialization part can get fiddly. Therefore try to use something that already works. In C#, I have used the SOAP formatter class[^] and it works well. You should look for something that exists for both your endpoints.
[/EDIT]


XML [^ ](可扩展标记语言)是一种协议(一组国际监管机构同意的规则),用于以文本格式(即,有些人类可读的形式)存储信息.

它通过Unicode支持从字母拼音到特殊字符的世界上所有字符集.

通过设计,XML可以表示层次结构(事物内部的事物),对象的属性等.

客户端-服务器方案何时,何地以及如何使用XML可能会有很大差异.同样,任何应用程序在何时何地使用XML的方式都可能相差很大.

对于您提到的每种使用情况,答案都是是的,也许是,甚至更多".例如,您可能会遇到这样的情况:一台机器发出XML(并且仅包含内部编码器,将其自身格式转换为XML),而接收方机器只能读取XML(仅包含将XML转换为其自身格式的转换器) )...但这不太可能.

在.NET C#[ ^ ]中,您已读取XML并编写内置的功能,您可以适应几乎可以想象的任何目的.

CodeProject上有大量资源可以帮助您使用XML [
XML[^] (Extensible Markup Language) is a protocol (a set of rules agreed upon by international regulatory bodies) for storing information in textual format (i.e., somewhat human readable form).

It supports, via Unicode, all the world''s character sets from alphabetic-phonetic through idiogramatic.

XML, by design, can represent hierarchy (things inside things), Attributes of Objects, etc.

When, where, and how, a client-server scenario uses XML can vary widely; similarly, when-where-how any application uses XML can vary widely.

For every usage scenario you mentioned, the answer is "yes, maybe, and ''even more''." You could have, for example, a scenario in which one machine sends out XML (and contains only an internal encoder from its own format to XML), and a receiving machine can only read XML (contains only a translator from XML to its own format) ... but that is very unlikely.

In .NET C#[^] you have XML read and write functionality built-in that you can adapt for almost any purpose you can imagine.

There are great resources here on CodeProject to help you with XML[^]


Xml只是旨在存储数据的文本文件.它通过在标签之间以文本形式存储信息来做到这一点.要获得出色的教程,请访问此网站 XML简介-W3学校 [
Xml is just a text file that is designed only to store data. It does this by storing information as text in between tags. For an excellent tutorial, take a look at this web site XML Introduction - W3 Schools[^].


这篇关于xml是如何工作的,并且用于存储数据或传输数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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