sax

How would you use Java to handle various XML documents?

I'm looking for the best method to parse various XML documents using a Java application. I'm currently doing this with SAX and a custom content handler and it works great - zippy and stable. I've decided to explore the option having the same program, that currently recieves a single format XML document, receive two additional XML docu...

How do I encode arbitrary data to XML using Java 1.4 and SAX?

We use SAX to parse XML because it does not require the entire XML document to be read into memory in order to parse a single value. I read many articles that insisted SAX can only be used to parse/decode XML and not create it. Is this true? ...

SAX vs XmlTextReader - SAX in C#

I am attempting to read a large XML document and I wanted to do it in chunks vs XmlDocument's way of reading the entire file into memory. I know I can use XmlTextReader to do this but I was wondering if anyone has used SAX for .NET? I know Java developers swear by it and I was wondering if it is worth giving it a try and if so what are t...

How to output a CDATA section from a Sax XmlHandler

This is a followup question of How to encode characters from Oracle to Xml? In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler. When I try to output characters in a CDATA Section: It happens basically like this: xmlHandler.startEleme...

How to Parsing "Event XML" in Java?

I'm looking to use Java to parse an ongoing stream of event drive XML generated by a remote device. Here's a simplified sample of two events: <?xml version="1.0"?> <Event> DeviceEventMsg <Param1>SomeParmValue</Param1> </Event> <?xml version="1.0"?> <Event> DeviceEventMsg <Param1>SomeParmValue</Param1> </Event> It seems like SAX is mo...

Reading a single XML document from a stream using dom4j

I'm trying to read a single XML document from stream at a time using dom4j, process it, then proceed to the next document on the stream. Unfortunately, dom4j's SAXReader (using JAXP under the covers) keeps reading and chokes on the following document element. Is there a way to get the SAXReader to stop reading the stream once it finds ...

Passing-through unknown XML elements in a SAX parser

I am loading some data from an XML document, modifying it, and writing back out to XML. The reading is done using a SAX parser library and the writing is done with a piece of custom code. Sometimes, the file is modified externally, and extra elements are added (such as references to stylesheets). Rather than losing these extra element...

SAX parser breaking on ñ

I have implemented a SAX parser in Java by extending the default handler. The XML has a ñ in its content. When it hits this character it breaks. I print out the char array in the character method and it simply ends with the character before the ñ. The parser seems to stop after this as no other methods are called even though there is sti...

Java SAX Parser raises UnknownHostException

The XML file I want to parse starts with : <!DOCTYPE plist PUBLIC "-//...//DTD PLIST 1.0//EN" "http://www.....dtd"&gt; So when I start the SAX praser, it tries to access this DTD online, and I get a java.net.UnknownHostException. I cannot modify the XML file before feeding it to the SAX parser I have to run even with no internet co...

How to call web service with Android

I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manually with SAX. ... Ok, that's fine but it's 2008 so I figured there should be some good l...

Parsing very large XML documents (and a bit more) in java

(All of the following is to be written in Java) I have to build an application that will take as input XML documents that are, potentially, very large. The document is encrypted -- not with XMLsec, but with my client's preexisting encryption algorithm -- will be processed in three phases: First, the stream will be decrypted according ...

Nesting SAX ContentHandlers

I would like to parse a document using SAX, and create a subdocument from some of the elements, while processing others purely with SAX. So, given this document: <DOC> <small> <element /> </small> <entries> <!-- thousands here --> </entries> </DOC> I would like to parse the DOC and DOC/entries elements...

How do I manage to get a non-null name argument with org.xml.sax.ext.EntityResolver2 resolveEntity method ?

In Java SAX processing, I dot not manage to obtain entity reference names from the org.xml.sax.ext.EntityResolver2 resolveEntity method. The name argument is always null even if the documentation states that "'name' is never null when invoked by a SAX2 parser". Any idea ? To demonstrate the issue, I have created a Jython 2.5 script. I...

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 easy access to elements of xml streams, or case where you just need to pull some information...

Snippet for SAX parsing a user object in C++?

Can anyone share a snippet of code where they parsed a user defined object using SAX parser in C++. ...

RE: Big XML file

Followup question to Big XML File: First thanks a lot for yours answers. After… what I do wrong? This is my class which uses SAX: public class SAXParserXML extends DefaultHandler { public static void ParcourXML() { DefaultHandler handler = new SAXParserXML(); SAXParserFactory factory = SAXParserFactory.newInstance(); ...

SAX Parser In Applet Failure

I have a very simple line of code in my source: XMLReader xmlReaderFactory = XMLReaderFactory.createXMLReader(); This works flawlessly from an application, however, from an applet, it attempts to load a ".class" file from the server (no classname, just the extension just as you see) and then fails to give me a parser. Exception in th...

Can I create an XML document from dtd file in Java?

I have a simple DTD file with elements and attributes specifications. Can i create a suitable XML file (with DOM) parsing this DTD with Java and no external APIs? Thanks in advance ...

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 option. Recently I found that XPath too provides a simple way to find nodes. But I'm not ...

Python SAX parser says XML file is not well-formed.

I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how do I fix it? Edit: I ...