首頁  >  文章  >  後端開發  >  XML入門的常見問題(一)

XML入門的常見問題(一)

黄舟
黄舟原創
2016-12-22 17:32:531586瀏覽

 一般問題

  什麼是 xml?

  可擴充標記語言 (XML) 是 Web 上的資料通用語言。它使開發人員能夠將結構化數據,從許多不同的應用程式傳遞到桌面,進行本地計算和演示。 XML 允許為特定應用程式建立唯一的資料格式。它還是在伺服器之間傳輸結構化資料的理想格式。

  什麼是 MSXML?

  MSXML 是提供核心 XML 服務的 Microsoft 軟體元件。

  Microsoft XML 分析器能夠做什麼?

  最新版本的 Microsoft 核心 XML 服務提供以下四種不同的功能。

  基於文件物件模型(DOM) 的分析器,它能夠取得文字流(能夠轉換到XML 的檔案、程式中的字串或任何其他文字)並將它轉換為能夠程式設計處理的可導航XML 樹結構。

  SAX(Simple API for XML)分析器,它針對處理大型文件和高吞吐量的情況進行了最佳化的。 SAX 是基於事件的分析器,它讀取文件並將分析事件(例如元素的開始和結尾)直接報告給應用程式。使用者創建的應用程式實現了處理不同事件的處理程序,這非常類似於處理圖形使用者介面 (GUI) 中的事件。

  XSLT 處理器讀取 XSLT 文件,並將可擴充樣式表轉換語言 (XSLT) 檔案的指令套用到 XML 文件,以產生某些類型的輸出。除了創建 XML結構之外,XSLT 處理器還可以在得到的 XSLT 過濾器上執行一定量的最佳化,另外,從技術的角度來看,它更像是一種編譯器。

  驗證分析器讀取文檔類型定義 (DTD) 或 XML 架構,然後檢驗實際得到的文檔的格式是否正確,以及是否不包含與架構衝突的資料。請注意,僅對架構而言,驗證架構將返回架構本身作為對象,可以在以後在 HTML 列錶框中建立選項時引用這個對象。 
  所有四種功能都包含在同一 MSXML 庫軟體包中,它可以從 MSDN XML 開發人員中心(英文)免費獲得。

  MSXML、MSXML2 和 MSXML3 之間的差異是什麼?

  在過去三年中 XML 經歷了許多反复,所以目前存在不同版本的 Microsoft XML 分析器也不奇怪。 Internet Explorer 4.0 包含早期版本的 XML 分析器,它比 XSL、XML 資料或大多數其他的 XML 技術(並且有完全不同的 DOM 模型)要早。此早期版本的分析器包含在 MSXML.dll 庫中。從 MSDN XML 開發人員中心(英文)可將分析器升級到較新的一種。

  我們極力建議您升級到新的分析器,因為它要強大得多。 Internet Explorer 5.0 包含 MSXML 2.0 分析器,它包含 XSL 和 XML 架構的基本版本。 MSXML2 是 SQL Server 2000 隨附的分析器版本。 MSXML2 包含了許多效能增強的功能,並且在整體上提高了效能和可擴展性。 MSXML3 是目前​​作為「技術預覽」附帶的版本。 MSXML3 包含 XSLT 和 XPath 支援以及 SAX 介面。

  XML 可以取代 HTML 嗎?

  XML 比 HTML 提供更大的彈性,但是它不可能很快取代 HTML。實際上,XML 和 HTML 能夠很好地在一起工作。 Microsoft 希望許多作者和開發人員都能同時使用 XML 和 HTML,例如用 XSLT 來產生 HTML。

  在 HTML 中增加 XML 的好處是什麼?

  在 Web 上使用 XML 的好處有:

  它提供用於本地計算的資料。傳遞到桌面的資料可以進行本地計算。 XML 分析器可以讀取數據,並將它遞交給本機應用程式(例如瀏覽器)以進一步查看或處理。資料也可以由使用 XML 物件模型的腳本或其他程式語言來處理。

  提供使用者正確的結構化資料視圖。傳遞到桌面的資料可以以多種方式表示。本地資料集,可以根據使用者喜好和配置等因素,以適當的形式,在視圖中動態表現給使用者。

  允許整合不同來源的結構化資料。一般情況下,使用代理,在中間層伺服器上整合來自後端資料庫和其他應用程式的數據,使該資料能夠傳遞給桌面或其他伺服器,做進一步聚合、處理和分佈。

  描述來自多種應用程式的資料。由於 XML 是可擴展的,因此它可以用於描述來自多種應用程式的數據,從描述 Web 頁面集合到數據記錄。由於資料是自描述的,因此不需要資料的內建描述,也能夠接收和處理資料。

  透過粒度更新來提高效能。 XML 允許粒度更新。開發人員不必在每次有改動時都傳送整個結構化資料集。有了粒度更新後,只有改變的元素必須從伺服器傳送到客戶機。改變的資料可以在不必刷新整個頁面或表格的情況下顯示。

  XML 只適用於核心開發人員嗎?

 No. Like HTML documents, XML documents can be created by anyone—even people without any programming experience. XML is simply a standard way of describing information. Additionally, it is a language that can be written in without any software. You can write an XML document in a text editor and place it directly into a Web site without writing any code in the traditional way.

 What do you need to start using XML?

  To use XML, you need an XML parser that can read an XML document and make its content processable. Microsoft provides a parser that can be downloaded from the MSDN XML Developer Center (in English).

  To work with XML documents, you can use a text editor such as Notepad or any other editor that can be used to create HTML pages. To create full-form XML applications, use a programming environment such as Microsoft® Visual Studio®.

  Are there any practical examples of how to use XML?

 XML is being used in a staggering number of applications, ranging from Web site creation and documentation to database integration and distributed programming. XML has its place in the following areas:

 Business-to-business transmission. Business data (invoices, purchase orders, accounting and tax information, etc.) are transferred electronically between vendors in XML format. XML offers many advantages over older electronic data interchange (EDI) formats beyond the ability to convert from one invoice format to another on the fly.

 Distributed programming. XML is ideal for constructing complex multi-platform applications, making integration with Windows Server and other operating systems possible.

 Web site architecture. Because of XML's hierarchical and distributed nature, Web site developers are increasingly using it in the overall architecture and navigation structure of their Web sites. In addition, more and more directory and index tables, XML structures that track user information and Web site status, HTML-based components, and channels for handling data flows are written in XML and XSLT.

 Database operations. XML is becoming a popular tool for interacting with databases—whether retrieving XML data sets from SQL queries or updating databases with XML records. And we also have the advantage of separate implementation. By compressing the data into SML, no knowledge of the actual database structure is required.

 Document management. Most companies today are mired in a sea of ​​paperwork, and it’s only going to get worse. XML is increasingly being used to encode documents into XML, making the document easier to retrieve or providing annotation context linked to the document for more efficient reference.

  Can I ignore XML?

 If you want to compete in the Internet world, you can't ignore XML. XML is a language that leads to a schema shift in the way we think about programming itself. Traditional dedicated client/server applications are giving way to "access anywhere, anytime" Internet services, and XML is the logical medium to handle everything from data access processing to representing data in this new environment.

 Does Microsoft Internet Explorer 4.0 support XML?

 Yes. Internet Explorer 4.0 supports the following XML features: A general-purpose XML parser that reads XML files and passes them to an application (such as a viewer) for processing. Application developers can use two parsers from Microsoft: Microsoft XML Parser in C++ and Microsoft XML Parser in Java.

  XML Object Model (XML OM) uses the World Wide Web Consortium (W3C) standard Document Object Model (DOM) to allow programs to access structured data through XML parsers, giving developers the ability to interact and calculate data. For more information, see the DOM Specification (English).

 XML Data Source Object (XML DSO) allows developers to connect to structured XML data and provide it to HTML pages using dynamic HTML's data binding mechanism.

The above is the content of the frequently asked questions about getting started with XML (1). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn