sax

Skipping nodes with sax

Is it possible to skip nodes when parsing and how, does this skippedEntity have anything to do with it? Consider this XML : <?xml version="1.0"?> <nutrition> <daily-values> <total-fat units="g">65</total-fat> <saturated-fat units="g">20</saturated-fat> <cholesterol units="mg">300</cholesterol> <sodium units="mg">2400<...

XPATH based content extraction from html pages

Hi, I m trying to extract content based on given xpath. When it is just one element i want to extract, there is no issue. When I have a list of items matching that xpath, then i get the nodelist and i can extract the values. However, there are a couple items related to each other forming a group, and that group repeats itself. One way ...

Using SAXXMLReader with large zipped xml files.

I'm really kind of surprised I couldn't find an answer to this on Google. Especially since xml files lend themselves to being zipped since they are so verbose. I'm implementing the sax reader from the msxml library in my VB6 program to read large multi-gigabyte xml files from a zip file. Unzipping these files to the hard drive and then ...

CDATA XML is truncated while parsing

Hi, I'm using a SAX parser (on android) to parse an xml file from an WebService. On some elements the CDATA is truncated and not complete, e.g. the XML-file contains data like <name><![CDATA[Gölsder und Ginck GmbH]]></name> and after parsing the xml file with public void characters(char[] ch, int start, int length) throws SAX...

Preserve newlines when parsing xml

I'm using the SAX xml parser to parse some xml data which contains newlines. When using Attributes#getValue, the newline data is lost. How can keep the newlines? ...

Using SAX to parse common XML elements

I'm currently using SAX (Java) to parse a a handful of different XML documents, with each document representing different data and having slightly different structures. For this reason, each XML document is handled by a different SAX class (subclassing DefaultHandler). However, there are some XML structures that can appear in all these ...

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

Hi, 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 = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); FeedHandler handler = new FeedHandler(); Input...

Returning XML from query result in servlet

Hi, I'm trying to return an XML file based on my query results. I'm very new to this so I'm not really sure where I'm going wrong. Is this a realistic way to go about doing this or is there something simpler? Right now I'm getting these exceptions: Error performing query: javax.servlet.ServletException: org.xml.sax.SAXParseException: Co...

Java XML Parsing and original byte offsets.

I'd like to parse some well-formed XML into a DOM, but I'd like know the offset of each node's tag in the original media. For example, if I had an XML document with the content something like: <html> <body> <div>text</div> </body> </html> I'd like to know that the node starts at offset 13 in the original media, and (more importantly...

Exiting from Xml.parse when match is found

Hi, I'm using the Android SAX parser to search for entries in a rather large (6MB) XML file. I'm basically using a derivative of the code shown in listing 8 here. The question I have is how do I stop parsing once my match has been found? The code shown continues parsing through the end of the file but I want to stop before then. Is this ...

Efficient XSLT pipeline, with params, in Java

Hi, The top answer to this question describes a technique to implement an efficient XSLT pipeline in Java: http://stackoverflow.com/questions/1312406/efficient-xslt-pipeline-in-java-or-redirecting-results-to-sources Unfortunately, while Transformer seems to expose an API for setting XSLT parameters, this does not seem to have any eff...

Java XML SAX Error Handling

So say I have an xml file that looks like this: <foo> <bar></bar> <bar></bar> <bar></bar> ... <bar></bar> </foo> My goal is to validate each bar tag against a DTD. For simplicity, lets say that for each bar node that passes validation against the DTD the program outputs "true" and each bar node that fails it outputs "fail" Using...

Problem parsing XML document with Java SAX

Hello everyone, I am parsing an XML document. I have done this thousands of times before, but I can't see why I am getting the following issue: Here is the relevant part of the XML document that I am parsing: XML: <?xml version="1.0" standalone="yes"?> <ratings> <url_template>http://api.netflix.com/users/T1BlCJtdcWMuF6gJEfue96_W.kZ_gW...

Is there a SAX Parser for Delphi and Free Pascal?

Besides MSXML and SAX for Pascal, can you recommend a SAX parser for Delphi? It would be great if it could be used in cross-platform applications with Free Pascal. ...

Android REST XML result to Listview

I have a REST web service that returns an xml result like this: - <MyCategories xmlns="http://schemas.datacontract.org/2004/07/ceva" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt; - <Category> <CategoryName>First category</CategoryName> <Id>1</Id> </Category> - <Category> <CategoryName>Second category</CategoryName> ...

How to parse different XML files using SAX on Android

Hey there, I have the following scenario: I send a XML file to a server as a request and get a XML file as response and all that as a background thread on android. The XML request is serialized using various values. The XML response is then read by SAX and put into a list. The whole request/response process happens in a background thre...

How to branch a SAX parser depending on the first known tag.

I'm having hard times parsing multiple different XML files on Android using the built-in SAX parser. Nate and Aron Saunders have helped me with the right approach to this problem but I struggle in implementing it. You can read about it here. http://stackoverflow.com/questions/3583876/how-to-parse-different-xml-files-using-sax-on-androi...

SAX parser ignoring CDATA - html tags

Hello, I have a simple Android RSS reader app in which I am using SAX parser to fetch the data. All the records are being fetched correctly except for the "desc" element. The XML structure is as below. <item> <title>Boilermaker Jazz Band</title> <link>http://eventur.sis.pitt.edu/event.jsp?e_id=1805&lt;/link&gt; <type>Music Concerts</ty...

How to read large XML file consisting of large number of small items efficiently in Java?

I have a large XML file that consists of relatively fixed size items i.e. <rootElem> <item>...</item> <item>...</item> <item>...</item> <rootElem> The item elements are relatively shallow and typically rather small ( <100 KB), but there may be a lot of them (hundreds of thousands). The items are completely independent of each o...

XML SAX parser for scripting using reflection

I'd like an opinion about to create an hypothetic scripting system using XML. The idea is to use a SAX parser and C# reflection. I cannot find a library/framework which allow to specify custom action using XML files. At this time I use XML for serialize application classes, bug could be awesome to specify which actions the application s...