Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 357 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
357
Dung lượng
3,5 MB
Nội dung
[...]... searching here for "XML" and various keywords related to your industry (especially the names of major industry consortia) 1.3 The Power of Python and XML Now that we've introduced you to the world of XML, we'll look at what Python brings to the table We'll review the Python features that apply to XML, and then we'll give some specific examples of Python with XML As a very high-level language, Python includes... target of a link is important to the linking document 2.5 Constructing XML Documents Documents are the heart of XML Any amount of usable XML is presented as a document, often stored in a file One of the very first things you must understand in order to use XML is how to create a well-formed document In this section, we examine the syntactic components of a document, starting with the individual characters... characters within your XML document, you'll need to encode them using entity or character references To turn the example into proper XML, we need to use this: Is 5 < 7 x2263; 9? Entity references are discussed later in this chapter, although many of you who have worked with HTML will find them familiar as they include ' ('), " ("), < () XML allows you to... specification defines a collection of text to be an XML document if it is wellformed according to the rules of the specification The term well-formed is widely used in XML, and it refers to a document that is syntactically acceptable For example: < ?xml version="1.0"?> Python and XML The preceding document is well-formed That is, beyond the XML declaration (described in more detail... same data in 2021? With XML, you can read the data with any text editor Let's look at this chapter in XML Using markup from a common document type for software manuals and documentation (DocBook), it appears somewhat verbose, and doesn't include change-tracking information, but we can identify the text quite easily now: Python and XMLPython and XML are two very different... by Python' s standard library of a variety of common interfaces, the value of creating reusable objects is easily recognized, all while the ease of implementing useful interfaces is maintained 1.3.1 Python Tools for XML Three major packages provide Python tools for working with XML These are, from the most commonly used to the largest: 1 The Python standard library 2 PyXML, produced by the Python XML. .. write an XML parser, the topic of characters and standardization would be of incredible importance to you For the rest of us, it's usually enough to choose an XML parser that gets it right You can declare the character encoding used in an XML document using the optional XML declaration: < ?xml version="1.0" encoding="UTF-8"?> For an external entity that is not a document itself, a variation of the XML declaration,... allows the content of XML documents to be labeled with the actual language it is written in, but that's not used as much as it could be at this time Since XML documents are Unicode documents, the languages of the world are supported The use of Unicode and encodings in XML are discussed in some detail in Chapter 2 Unicode strings have been a part of Python since Version 2.0, and the Python standard library... in large databases Many XML documents involve more than one entity; perhaps the most common arrangement is that the document is in one entity and its type definition is in another As documents get larger, increasing numbers of entities are often involved with each document This may be more common with document-centric applications than with data-communication applications of XML Entities are typically... not generally a difficult specification to read 1.2.2 Namespaces in XML While the XML 1.0 recommendation defines specific syntactic aspects of XML and one way of creating document types, it does not discuss how to combine components from multiple document types The Namespaces in XML recommendation, available at http://www.w3.org/TR/REC -xml- names (referred to as Namespaces from now on), deals with the . version="1.0"?>
<address>
<name>Bubba McBubba</name>
<street>123 Happy Go Lucky Ln.</street>
<city>Seattle</city><state>WA</state><zip>98056</zip>.
<chapter>
<title> ;Python and XML& lt;/title>
<para> ;Python and XML are two very different animals, each with a
rich history. Python