站内搜索: 请输入搜索关键词
当前页面: 图书首页 > NET For Java Developers Migrating To C#

NET For Java Developers Migrating To C#

[ directory ] Previous Section Next Section

Chapter 20. Processing XML

Like the popular HTML, Extensible Markup Language (XML) consists of tagged, human-readable text. Unlike HTML, the tags in an XML document follow one simple rule: For every opening tag <tag> there is a closing tag </tag> . An XML document in which every opening tag has a closing tag is said to be well formed.

As long as the XML document is well formed, you can fabricate the tags in any way you want. An XML document is typically parsed by an XML parser, which creates an in-memory logical data structure for navigating the document. There are different types of XML parsers. The most common do not usually care what the tags are as long as they are well formed. Sometimes a parser can validate an XML document against a set of rules that limit the document to only a certain subset of tags. Such parsers are called validating parsers.

The two most popular mechanisms for parsing XML documents are to create a Document Object Model (DOM) tree or to use the event-based Simple API for XML (SAX) model. An XML document can be validated against a DTD (the set of rules that define the type and structure of the XML tags) or an XML schema.

This chapter looks at C#'s API for DOM and SAX parsing of XML documents. We look at validating an XML document against a DTD. We also look at other utilities, such as XPath and Extensible Stylesheet Transformation (XSLT), that are built into the .NET API.

    [ directory ] Previous Section Next Section