TAILIEUCHUNG - Dive Into Python-Chapter 9. XML

Tham khảo tài liệu 'dive into python-chapter 9. xml', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 9. XML Processing . Diving in These next two chapters are about XML processing in Python. It would be helpful if you already knew what an XML document looks like that it s made up of structured tags to form a hierarchy of elements and so on. If this doesn t make sense to you there are many XML tutorials that can explain the basics. If you re not particularly interested in XML you should still read these chapters which cover important topics like Python packages Unicode command line arguments and how to use getattr for method dispatching. Being a philosophy major is not required although if you have ever had the misfortune of being subjected to the writings of Immanuel Kant you will appreciate the example program a lot more than if you majored in something useful like computer science. There are two basic ways to work with XML. One is called SAX Simple API for XML and it works by reading the XML a little bit at a time and calling a method for each element it finds. If you read Chapter 8 HTML Processing this should sound familiar because that s how the sgmllib module works. The other is called DOM Document Object Model and it works by reading in the entire XML document at once and creating an internal representation of it using native Python classes linked in a tree structure. Python has standard modules for both kinds of parsing but this chapter will only deal with using the DOM. The following is a complete Python program which generates pseudo-random output based on a context-free grammar defined in an XML format. Don t worry yet if you don t understand what that means you ll examine both the program s input and its output in more depth throughout these next two chapters. Example . If you have not already done so you can download this and other examples used in this book. Kant Generator for Python Generates mock philosophy based on a context-free grammar Usage python options source Options -g . --grammar . use specified grammar file or .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.