Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Why do you have Harmony on your build path? Your code works fine with the built-in SAXParser in Oracle's JDK7u3. If there isn't a reason to be using the harmony implementation, you should revert to the standard one.</p> <p>Testcase form:</p> <pre><code>import java.io.IOException; import java.io.StringReader; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; class Scratch { public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException { final String document = "&lt;?xml version=\"1.0\"?&gt;\n" + "&lt;rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\"&gt;\n" + " &lt;channel&gt;\n" + " &lt;title&gt;Torrentz - ubuntu&lt;/title&gt;\n" + " &lt;link&gt;http://torrentz.eu/verified?q=ubuntu&lt;/link&gt;\n" + " &lt;description&gt;ubuntu search&lt;/description&gt;\n" + " &lt;language&gt;en-us&lt;/language&gt;\n" + " &lt;atom:link href=\"http://torrentz.eu/feed_verifiedP?q=ubuntu\" rel=\"self\" type=\"application/rss+xml\" /&gt;\n" + " &lt;item&gt;\n" + " &lt;title&gt;ubuntu 11 10 desktop i386 iso&lt;/title&gt;\n" + " &lt;link&gt;http://torrentz.eu/8ac3731ad4b039c05393b5404afa6e7397810b41&lt;/link&gt;\n" + " &lt;guid&gt;http://torrentz.eu/8ac3731ad4b039c05393b5404afa6e7397810b41&lt;/guid&gt;\n" + " &lt;pubDate&gt;Thu, 13 Oct 2011 15:02:06 +0000&lt;/pubDate&gt;\n" + " &lt;category&gt;apps linux applications os software&lt;/category&gt;\n" + " &lt;description&gt;Size: 695 MB Seeds: 4,613 Peers: 161 Hash: 8ac3731ad4b039c05393b5404afa6e7397810b41&lt;/description&gt;\n" + " &lt;/item&gt;\n" + " &lt;/channel&gt;\n" + "&lt;/rss&gt;\n"; SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); ContentHandler torrentsHandler = new DefaultHandler() { @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { System.out.printf("%s / %s / %s\n", uri, localName, qName); } }; xr.setContentHandler(torrentsHandler); xr.parse(new InputSource(new StringReader(document))); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload