利用vb操作xml数据(Using VB to operate XML data).doc
《利用vb操作xml数据(Using VB to operate XML data).doc》由会员分享,可在线阅读,更多相关《利用vb操作xml数据(Using VB to operate XML data).doc(22页珍藏版)》请在三一文库上搜索。
1、利用vb操作xml数据(Using VB to operate XML data)What is XML?The extensible markup language XML is a simple data storage language, using a series of simple tags to describe data, and these markers can be used to establish a convenient way, although the XML space to occupy more space than the binary data, bu
2、t XML is extremely simple and easy to master and use.XML and Access, Oracle and SQL Server database, the database provides the data storage and analysis capabilities, more powerful such as data indexing, sorting, searching, consistency, XML is only the display of data. In fact, the biggest differenc
3、e between XML and other forms of data is that he is extremely simple. This is a look a little petty advantages, but it is in this respect that XML out of the ordinary.Simple XML to make it easy to read and write data in any application, the XML soon became the only common language of data exchange,
4、although different applications also support other data exchange format, but soon they will support XML, it means that the program can be more easily with Windows, Mac OS Linux, and other platforms combined with the information, and then can easily load XML data into the program and his analysis, an
5、d XML format output results.Advantages of XMLWe talked about XML longer than the exchange of data between different applications, the XML file is to facilitate the construction of a small database, not long ago, the use of INI file storage software configuration information, user preferences and oth
6、er information, then Microsoft introduced the system registry, then Microsoft told we should not use the INI file, since then Visual Basic of the INI file support weakened. Unfortunately, the registry has several fatal drawbacks: it is not a simple text file to read and write, may become large and s
7、low, if the registry is somehow there is a problem, it may cause system crashes.The configuration information in the XML file to avoid these problems, even the XML file can be set to a file sharing in different computer users can share data, which is incomparable to the registry.In the ASP.NET that
8、is called the next generation ASP, you can use XML directly in the WEB page. You can bind data directly and automatically display using the data bound controls.Of course, you can not choose XML, the use of text files, registry, database, you can complete the task XML can complete, XML is just anothe
9、r tool you store and restore data.A brief introduction to XML grammarThe XML syntax is very simple, XML document consists of nodes, the use of open and close nodes in the format and description tags, HTML tags are very similar, the biggest difference between them is free to define the tag name XML.
10、For example, the following tag describes a telephone number: 987-654-3210 But no statement can use the tag name.The start and end tags must be the same, and the XML is case sensitive, so the markup must be the same. For example, in the above example, the beginning of mark must end with mark, but not
11、 or Node tags can contain attributes, such as the Phone node in the code below contains the attribute Type, whose value is WorkFax: 987-654-3210 If you do not want to contain a value in the node, then do not need to mark the end, with a slash in the back to mark the beginning of the end node, in the
12、 following example, the Number attribute of the Phone tag is stored in a telephone number, there is no need for an end tag:The structure of a XML document is a tree hierarchy. The document must have a unique root node,The root node contains all the other nodes. Lets give you a more complete example:
13、 Andy Fickle 1234 Programmer Place Bugsville CO 82379 354-493-9489 Betty Masterson 937-878-4958 937-878-4900 .Note that similar nodes do not need to contain the same information, such as the first Entry node contains address information and home telephone number, the second Entry node contains the W
14、ork and WorkFax phone number, but does not include the first Entry node contains information.XML toolsAs in the previous example, the XML syntax is you can make a XML parser in a very short time so simple that, fortunately you do not have to do so, because the XML tool can be run on various platform
15、s, including the Visual Basic Windows can be installed.It is these L tools, not the XML itself, that make XML more powerful and complex. Different parsers allow you to load the entire XML document at any point or just load a node. On the contrary, XML Writer can create an XML document and a node at
16、the same time.The DOM parser enables us to easily load, copy, sort, modify, and store XML files, traverse the nodes to obtain names or attributes, and sort the results. Although their functions are not really relational, databases are powerful, but these features of DOM are still very useful.XSD def
17、ines the format of XML documents, and the XSL extended style sheet defines how to convert XML documents into other file formats that can be browsed in WEB browsers, such as HTML files.These tools are actually more complex than XML itself, so all of the books explaining XML have taken a lot of space
18、to explain these XML tools. But this is beyond the scope of this article, interested readers can refer to the relevant information.Visual Basic.Net provides a complete tool for using XML, XSL, and other XML tools. But without waiting for VB.NET, Microsoft XML core services (MSXML) version 4 provides
19、 tools to load and store XML documents from Visual Basic6.0.Download the latest version of MSXML in and install it on the computer. In Visual Basic 6 Microsoft XML V4.0 used as references to other objects, first select the reference menu item in the Project menu, select Microsoft V4.0, click OK, af
20、ter the completion of all you can now add the XML object in the VB application.Class DOMDocumentThe document object model (DOM) uses a series of corresponding objects to describe the hierarchical state of the XML document, and the DOMDocument class is a MSXML class that describes the DOM structure o
21、f the XML document.The DOMDocument class provides only a few useful properties and methods. The Load method loads a XML file, and the loadxml method adds the string as the XML data to the object. For example, the following code adds a small XML file to a document called xml_document.Dim xml_document
22、 As New DOMDocumentXml_document.loadXML _“人”vbcrlf和_“FirstName杆/名”vbcrlf和_“姓斯蒂芬斯/姓”vbcrlf和_“/人”属性返回文档的DOMDocument的XML XML描述,可以显示这些返回值看看这些文档究竟是什么样子,也可以将它存储为一个文件,但这完全不必要,因为DOMDocument对象的救方法已经自动将他们存储了。DOMDocument对象的属性表示文档数据的根结点通常情况下操作XML文档元素,文档都从这里开始。提供了几种创建新节点的方法DOMDocument。createElement方法为文档创建一个新的元素节
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 利用vb操作xml数据Using VB to operate XML data 利用 操作 数据 Using data
链接地址:https://www.31doc.com/p-9186671.html