473,799 Members | 3,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml.parsers.exp at vs. xml.sax

Hi!

What are the difference between xml.parsers.exp at
and xml.sax?

Up to now I used xml.sax.make_pa rser and subclass
from ContentHandler.

I think xml.sax.make_pa rser uses expat as default.
Why should I want to use xml.parsers.exp at?

Regards,
Thomas

Jul 18 '05 #1
2 3938
Hello,

I'm fairly new to Python but I've had a fair bit of experience
in SAX.

Basically xml.sax.XMLRead er is a simple implementation that doesn't
do anything when you call parse, setFeature etc. Expat is an
implementation of the XMLReader, therefore in actual fact you will never
know that you are using Expat as an SAX XMLReader implmentation and you
never should need to know - it is simply returned from make_parser The
reason that SAX has this mechanism is that it easily allows you to
switch implementations in and out. Take a look at the source code and
it immediatly becaomes clear!

This makes more sense in other languages which have formal
interfaces but Python doesn't have such a thing (although you can
acheive the same effect in other ways if you so desire).

PS I'm new to Python so if that's wrong for the Python SAX
implementation then please let me know!

Cheers,

Neil

Thomas Guettler wrote:
Hi!

What are the difference between xml.parsers.exp at
and xml.sax?

Up to now I used xml.sax.make_pa rser and subclass
from ContentHandler.

I think xml.sax.make_pa rser uses expat as default.
Why should I want to use xml.parsers.exp at?

Regards,
Thomas


--

Neil Benn
Senior Automation Engineer
Cenix BioScience
PfotenhauerStra sse 108
D-01307
Dresden
Germany

Tel : +49 (351) 210 1300
e-mail : be**@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com
Jul 18 '05 #2
Thomas Guettler wrote:
What are the difference between xml.parsers.exp at
and xml.sax?

Up to now I used xml.sax.make_pa rser and subclass
from ContentHandler.

I think xml.sax.make_pa rser uses expat as default.
Why should I want to use xml.parsers.exp at?


expat is slightly more low level. It *may* be more efficient but I
wouldn't care about that.

Using sax instead of expat is usually (always?) the right decision.
There is more published API for sax, knowledge carries over from other
languages, and sax has multiple implementations in Python.

Regards,

Martijn
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6064
by: Will Stuyvesant | last post by:
There seems to be no XML parser that can do validation in the Python Standard Libraries. And I am stuck with Python 2.1.1. until my web master upgrades (I use Python for CGI). I know pyXML has validating parsers, but I can not compile things on the (unix) webserver. And even if I could, the compiler I have access to would be different than what was used to compile python for CGI. I need to write a CGI script that does XML validation...
0
1468
by: dagurp | last post by:
I have this code: import xml.parsers.expat parser = xml.parsers.expat.ParserCreate(encoding="UTF-8") text = unicode("<div>þórður</div>",'UTF-8') print parser.Parse(text,1) And this is what I get: UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-6: ordinal not in range(128)
4
3802
by: Laurens | last post by:
Hi, Is there any good open-source C++ XML parser library that isn't as huge as Xerces? The Xerces DLL is about 2.4 Mb in size, which is far too big for my application. (It doesn't seem to be possible to link Xerces statically.) The parser doesn't need to do DTD/Schema validation, but it should be able to expand entities. I also need a DOM to navigate the document. XPath querying would be nice, but is not essential.
2
1171
by: Nikhil | last post by:
Hi, Does anybody knows faster parsers than C - RXP in validating category and Expat in non-validating category? Are both of them (or their faster ones) portable in Mac OS X? Thanks, Nikhil
1
1325
by: Avi Kak | last post by:
Hello: This questions relates to the behavior of the Perl SAX 2.0 parser XML::LibXML::SAX. (This behavior is also shown by the XML::SAX::Expat parser and, possibly by all other Perl SAX 2.0 parsers.) My understanding of a default namespace is that all unprefixed names get assigned to the default namespace at and below the level of the element in
1
1559
by: bloon | last post by:
I know there are three most popular open-source XML parsers. They are expat, libxml, and Xerces. All three are cross-platform. Does anybody test these three parsers? Which one is the fastest when loading and parsing large XML files? Thanks.
2
3744
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program that both eventually call the same code that imports xml.parsers.expat. Both give me different results... The code that gets called is (print statements have been added for debugging):
6
2648
by: kaens | last post by:
Hey everyone, this may be a stupid question, but I noticed the following and as I'm pretty new to using xml and python, I was wondering if I could get an explanation. Let's say I write a simple xml parser, for an xml file that just loads the content of each tag into a dict (the xml file doesn't have multiple hierarchies in it, it's flat other than the parent node) so we have <parent>
1
4222
by: josh logan | last post by:
Vincent Yau <y...@ohsu.eduwrites: Fast-forward to 2008 I installed Python 3.0b2 on a Windows Vista laptop (after having previously installed Python 2.5), and I am getting this same error: Traceback (most recent call last): File "Programming\Python\monkeys.py", line 24, in <module> test_parse(sys.argv)
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.