Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet294/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   290   291   292   293   294   295   296   297   ...   453
Working with xml.sax
It’s important to remember that SAX is an event-driven method of working with XML. An applica-
tion looks at a small number of bits out of an entire document. Consequently, SAX can be a good 
FIgURE 13-6: 
The Python output is similar, but not precisely 
the same as the .NET output.
548592c13.indd 283
2/24/10 12:48:59 PM
www.finebook.ir


284

CHAPTER 13
Working With XML Data
method for processing larger documents that you can’t read into memory at one time. A SAX appli-
cation normally relies on three constructs:

One or more sources as input

A parser (normally, only one is used)


One or more handlers to respond to input events


There are many different Python SAX modules. Each of these modules provides different imple-
mentations of the three constructions. The default SAX implementation provides just four handlers. 
These handlers are implemented as classes that you use to interact with the events generated by the 
input file.
➤➤
ContentHandler
: Provides the main SAX interface for handling document events. Most 
applications use this interface as a minimum because it provides the basic support required 
for any document. The example shows how to use this handler, which is provided as part of 
the 
xml.sax
module.


DTDHandler
: Manages all of the Document Type Definition (DTD) events.


EntityResolver
: Resolves external entities such as files referenced by processing 
instructions.


ErrorHandler
: Reports any errors or warnings that the parser encounters when it processes 
the XML. Provided as part of the 
xml.sax
module.
Now that you have a little better idea of what to expect, it’s time to look at an actual example. 
Listing 13-4 shows a simple SAX implementation that includes all of the constructs you normally 
need. Of course, you can easily add to this example to make it do considerably more than it does now.

Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   290   291   292   293   294   295   296   297   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish