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
0
votes
2 answers

Getting all elements

I have an XML document, that looks like this (I know, it doesn't make sense, it's just an example): Peter Sweden It can…
Evgenij Reznik
  • 17,916
  • 39
  • 104
  • 181
0
votes
1 answer

Sax Parser Character Array to Integer?

I am trying to get the contents of tags into variables in my java Sax parser. However, the Characters method only returns Char arrays. Is there anyway to get the Char array into an Int??? public void characters(char ch[], int start, int length)…
Schodemeiss
  • 1,144
  • 3
  • 16
  • 37
0
votes
4 answers

Java XML Parser -- how to collect or count a certain tag

I am trying to parse a simple XML file. If I have a bellow XML string, Tove Jani Reminder Don't forget me this weekend! I only want to extract string from …. I'm…
pandagrammer
  • 841
  • 2
  • 12
  • 24
0
votes
1 answer

How to send illegal XML elements in the body of a http request?

I am making a POST and posting data in xml format, but I want to pass values like <, >, and @. #,#,< I have a problem with the < and > characters. Is there any way to pass these values? I cannot change the input format.
berry_burr
  • 241
  • 4
  • 19
0
votes
2 answers

what is the absolute path to the res/raw folder in your app?

I have an xml file(thexml.xml) and it's related dtd(thedtd.dtd) file in res/raw folder. this is the DOCTYPE of the xmlfile: Because the address to the dtd file has been set relatively i get this…
Gandalf
  • 2,921
  • 5
  • 31
  • 44
0
votes
0 answers

How to parse an String xml to return all the traversal paths using Java

I am trying to parse an xml String to return all the traversal paths from root to depth. Please help to meet my requirement. My xml String is as below: 123 Leave Review by Manager
user1787641
  • 331
  • 2
  • 8
  • 25
0
votes
2 answers

Feed byte[] to SAXParser

I'm receiving byte arrays (actually, netty's ByteBufs) from underlying network layer in pipeline handler object like this: class Handler { ... private SAXParser parser = ...; private ContentHandler handler = ...; void process(byte[]…
Oroboros102
  • 2,214
  • 1
  • 27
  • 41
0
votes
2 answers

Sax parsing from web service

I am trying to parse xml file using Sax parser. The file has variable number of same elements. I want to count the number of times the element is present. And i want this count before parsing, so that I can declare an array of appropriate size. One…
donald
  • 1
  • 1
0
votes
1 answer

How to parse XML with xml.sax and why it's not working

I have a piece of code whitch in my opinion should work: #!/usr/bin/env python3 import xml.sax import xml.sax.handler class MyClass: def load_from_file(self, filename): class MyXmlHandler(xml.sax.handler.ContentHandler): …
BPS
  • 1,133
  • 1
  • 17
  • 38
0
votes
0 answers

dom vs sax vs stax when you need entire file anyway

I read that stax and sax are faster then DOM because they don't have to process the entire xml file. I saw speed comparisons with x number of files, but they didn't specify how much of the file they were accessing each time. If my understanding is…
gunfulker
  • 678
  • 6
  • 23
0
votes
4 answers

Why does my Sax Parser produce no results after using InputStream Read?

I have this piece of code which I'm hoping will be able to tell me how much data I have downloaded (and soon put it in a progress bar), and then parse the results through my Sax Parser. If I comment out basically everything above the //xr.parse(new…
Schodemeiss
  • 1,144
  • 3
  • 16
  • 37
0
votes
4 answers

How to determine that no exceptions have been caught java

I have a code for my xml file validation: try { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setValidating(true); DocumentBuilder builder = domFactory.newDocumentBuilder(); …
JulioBordeaux
  • 494
  • 1
  • 7
  • 23
0
votes
1 answer

Android SaxParser cannot parse nbsp;

I have been trying to fix this problem I am having with the SaxParser and an Atom Google Calendar feed. Basically the project that I am working on is pulling a Google Calendar feed from my college and placing it into a ListView, which when clicked…
0
votes
2 answers

SAX Parser returning empty string

I am trying to extract data from RSS feed. RSS link - http://www.thehindu.com/sport/?service=rss? Here are my default handler's character method. public void characters(char[] ch, int start, int length) { String text = ""; for (int i=0;…
anuragneo
  • 61
  • 1
  • 2
0
votes
1 answer

Java: parse xml file using SAX

I have this xml data to parse using SAX. The problem is that I cannot figure out how to get the data from it. The most important thing to get from it is the encoded data (fileContent) which I believe is base64. What I need to do with that is to make…
Comforse
  • 2,027
  • 4
  • 25
  • 40