Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 446 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
446
Dung lượng
2,02 MB
Nội dung
Python & XML Christopher A. Jones Fred L. Drake, Jr. Publisher: O'Reilly First Edition January 2002 ISBN: 0-596-00128-2, 384 pages Python is an ideal language for manipulating XML, and this new volume gives you a solid foundation for using these two languages together. Complete with practical examples that highlight common application tasks, the book starts with the basics then quickly progresses to complex topics like transforming XML with XSLT and querying XML with XPath. It also explores more advanced subjects, such as SOAP and distributed web services. [...]... 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... 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: The Python standard library PyXML, produced by the Python XML Special Interest Group 4Suite, provided by Fourthought, Inc The Python standard library provides a minimal but useful set of interfaces to work with XML, including an interface to the popular Expat XML. .. trivial If the code above is in bookhandler.py and our sample document is in books .xml, we could do this in an interactive session: >>> import xml. sax >>> import bookhandler >>> import pprint >>> >>> parser = xml. sax.make_parser( ) >>> handler = bookhandler.BookHandler( >>> parser.setContentHandler(handler) 24 IT-SC book ) >>> parser.parse("books .xml" ) >>> pprint.pprint(handler.mapping) {u'1-56592-051-1':... core language and libraries The more recent versions of Python, from 2.0 onward, include excellent support for Unicode and an impressive range of encodings, as well as an excellent (and fast!) XML parser that provides character data from XML as Unicode strings Python' s standard library also contains implementations of the industry-standard DOM and SAX interfaces for working with XML data, and additional... problem and what only might be a problem (How to perform the analysis and write extensions in C/C++ is a topic for other books.) Regardless of your feelings on scripting languages, Java, or C++, this book focuses on XML and the Python language For those who are new to XML, we will start with an overview of why it is interesting, and then we'll move on to using it from Python and seeing how we make our XML. .. 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 XML Python and XML are two very different... stylesheets, XSLT is an XMLbased language that is used to define transformations from XML to other formats XSLT is most commonly used with XML or HTML as the output format Chapter 6 describes this language and shows how to use it in Python 1.4 What Can We Do with It? Now that we've looked at how we can use XML with Python, we need to look at how we can apply our knowledge of XML and Python to real applications... for XML (SAX), and a basic implementation of the core Document Object Model (DOM) The DOM implementation supports Level 1 and much of Level 2 of the DOM specification from the W3C, but does not implement most of the optional features The material in the standard library was drawn from material originally in the PyXML package, and additional material was contributed by leading Python XML developers PyXML... language than the example of XML we just looked at, and writing a program that understands RTF would be quite difficult In this book, we're going to show you that XML can be used to define languages that fit your application, and that creating programs that can decipher XML is not a difficult task, especially with the help of Python 1.1.2 Hierarchical Structure XML is hierarchical, and allows you to choose... into both Python itself and the excellent selection of additional packages of Python code Python' s development has been beleaguered by regular employment changes, but we all owe a debt of gratitude to the employers of the contributors and the PythonLabs team Now at Zope Corporation (formerly Digital Creations), PythonLabs has finally found a home that offers both a rich environment for Python and comfortable . Acknowledgments 1. Python and XML 1.1 Key Advantages of XML 1.2 The XML Specifications 1.3 The Power of Python and XML 1.4 What Can We Do with It? 2. XML Fundamentals 2.1 XML Structure. Services, and SOAP 9.1 Python Web Services Support 9.2 The Emerging SOAP Standard 9.3 Python SOAP Options 9.4 Example SOAP Server and Client 9.5 What About XML- RPC? 10. Python and. Running the XML Switch 10.8 A Web Application A. Installing Python and XML Tools A.1 Installing Python A.2 Installing PyXML A.3 Installing 4Suite B. XML Definitions B.1 XML Definitions