Questions tagged [sax]

SAX stands for Simple API for XML, and is an event-based way of reading XML data from a document.

SAX (Simple API for XML) is an event-based sequential access parser API developed by the XML-DEV mailing list for XML documents.
SAX provides a mechanism for reading data from an XML document that is an alternative to that provided by the Document Object Model (DOM). Where the DOM operates on the document as a whole, SAX parsers operate on each piece of the XML document sequentially.

XML processing with SAX

A parser that implements SAX (i.e., a SAX Parser) functions as a stream parser, with an event-driven API. The user defines a number of callback methods that will be called when events occur during parsing. The SAX events include (among others):

Useful references:

1784 questions
90
votes
4 answers

XML parsing - ElementTree vs SAX and DOM

Python has several ways to parse XML... I understand the very basics of parsing with SAX. It functions as a stream parser, with an event-driven API. I understand the DOM parser also. It reads the XML into memory and converts it to objects that can…
Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
86
votes
6 answers

When should I choose SAX over StAX?

Streaming xml-parsers like SAX and StAX are faster and more memory efficient than parsers building a tree-structure like DOM-parsers. SAX is a push parser, meaning that it's an instance of the observer pattern (also called listener pattern). SAX was…
Rinke
  • 6,095
  • 4
  • 38
  • 55
61
votes
13 answers

Is there any XPath processor for SAX model?

I'm looking for an XPath evaluator that doesn't rebuild the whole DOM document to look for the nodes of a document: actually the object is to manage a large amount of XML data (ideally over 2Gb) with SAX model, which is very good for memory…
user189603
  • 611
  • 1
  • 7
  • 6
57
votes
3 answers

How to parse XML using the SAX parser

I'm following this tutorial. It works great but I would like it to return an array with all the strings instead of a single string with the last element. Any ideas how to do this?
Johan
  • 2,149
  • 4
  • 21
  • 18
36
votes
3 answers

How to set Saxon as the Xslt processor in Java?

This is a simple question, but one I cannot find the answer to. I have an XSLT 2.0 stylesheet that I'm trying to process in Java. It relies on XSL elements from Saxon. My current class works fine with simple XSLT 1.0, but I'm getting errors about…
Jeff
  • 877
  • 2
  • 11
  • 17
33
votes
3 answers

What is the difference between localname and qname?

When using SAX to parse an XML file in Java, what is the difference between the parameters localname and qname in SAX methods such as startElement(String uri, String localName,String qName, Attributes attributes)?
Bob
  • 331
  • 1
  • 3
  • 3
30
votes
2 answers

Howto let the SAX parser determine the encoding from the xml declaration?

I'm trying to parse xml files from different sources (over which I have little control). Most of the them are encoded in UTF-8 and don't cause any problems using the following snippet: SAXParserFactory factory =…
Allan
  • 549
  • 1
  • 4
  • 9
26
votes
2 answers

How to Parse Big (50 GB) XML Files in Java

Currently im trying to use a SAX Parser but about 3/4 through the file it just completely freezes up, i have tried allocating more memory etc but not getting any improvements. Is there any way to speed this up? A better method? Stripped it to bare…
Joe Maher
  • 5,354
  • 5
  • 28
  • 44
26
votes
3 answers

How to stop parsing xml document with SAX at any time?

I parse a big xml document with Sax, I want to stop parsing the document when some condition establish? How to do?
Diablo.Wu
  • 1,151
  • 5
  • 15
  • 17
26
votes
2 answers

ElementTree iterparse strategy

I have to handle xml documents that are big enough (up to 1GB) and parse them with python. I am using the iterparse() function (SAX style parsing). My concern is the following, imagine you have an xml like this
Juan Antonio Gomez Moriano
  • 13,103
  • 10
  • 47
  • 65
26
votes
2 answers

Cure for 'The string "--" is not permitted within comments.' exception?

I'm using Java 6. I have this dependency in my pom ... xerces xercesImpl 2.10.0
Dave
  • 15,639
  • 133
  • 442
  • 830
25
votes
4 answers

How to select saxon TransformerFactory in Java

In my web application I need to use Saxon TransformerFactory in order to use XSLT 2.0 but I can't use setProperty method because I don't have this right on the web server and there is a Security Manager. So I have read that it should be possible to…
pAkY88
  • 6,262
  • 11
  • 46
  • 58
24
votes
5 answers

Is XPath much more efficient as compared to DOM and SAX?

I need to parse an xml string and find values of specific text nodes, attribute values etc. I'm doing this in javascript and was using the DOMParser class for the same. Later I was informed that DOM is takes up a lot of memory and SAX is a better…
sundeep
  • 1,792
  • 1
  • 15
  • 21
23
votes
3 answers

Is there a SaxParser that reads json and fires events so it looks like xml

This would be great as it would allow my xml stuff to read json w/out any change except for the different sax parser.
mP.
  • 18,002
  • 10
  • 71
  • 105
21
votes
4 answers

What ever happened to XPathReader

XPathReader is/ was an implementation of a forward reading XML parser (built on XMLReader) which allowed you to register XPath queries for it to find (or at least a subset of XPath called Sequential XPath). This seems to be the perfect choice for…
philsquared
  • 22,403
  • 12
  • 69
  • 98
1
2 3
99 100