Xpath4sax - XPath for SAX XML Parser

  •        562

A quick XPath analyser with a SAX Parser. Some syntaxes are invalide, but all using syntax are presents. It's possible to catch many XPath in the same time. XPathXMLHandler handler=new XPathXMLHandler() { @Override public void findXPathNode(SAXXPath xpath, Object node) { System.out.println("node="+node); } };handler.setXPaths(XPathXMLHandler.toXPaths("//b[@at_a='s3']/c"));SAXParser parser = SAXParserFactory.newInstance().newSAXParser();parser.parse(new InputSource(new StringReader(xml)), handler);The node is orphan, with attributs and all child texts nodes. It's possible to use with HtmlParser. XPathXMLHandler handler=new XPathXMLHandler(){ @Override public void findXpathNode(SAXXPath xpath, Object node) { System.out.println("node="+node); }};handler.setXPaths(XPathXMLHandler.toXPaths("//body/h1"));HtmlParser htmlParser = new HtmlParser(XmlViolationPolicy.ALLOW);htmlParser.setDoctypeExpectation(DoctypeExpectation.NO_DOCTYPE_ERRORS);htmlParser.setContentHandler(handler);htmlParser.parse(new InputSource(new StringReader(html)));Accepted syntax

http://code.google.com/p/xpath4sax

Tags
Implementation
License
Platform

   




Related Projects

vim-olive - Vim Mode Line Verifier


Vim Mode Line Verifier

vim-mash - Motion Activated Search Highlighter for Vim


Motion Activated Search Highlighter for Vim

vim-grillz - Flash your wicked grillz!


Flash your wicked grillz!

vim-foist - Complete whole lines from any partial therein


Complete whole lines from any partial therein

vim-efmc - Vim Error Format Compiler


Vim Error Format Compiler


uzbl-utrs - mkng uzbl tlrbl


mkng uzbl tlrbl

toycsv - A toy CSV parser written in ruby + lexr + racc


A toy CSV parser written in ruby + lexr + racc

tiktok - TikTok provides a simple asynchronous timer object for VimL.


TikTok provides a simple asynchronous timer object for VimL.

tabby - Using Vim's Tabs the Right Way


Using Vim's Tabs the Right Way

SohiVila - GNU source-highlight Vim language


GNU source-highlight Vim language

SinTax - A DSL for generating Vim syntax highlighting files


A DSL for generating Vim syntax highlighting files

rkdots - Generate a graphviz visualisation of the given javascript statement.


Generate a graphviz visualisation of the given javascript statement.

RelNumBar - Show relativenumbers alongside normal numbers in Vim


Show relativenumbers alongside normal numbers in Vim

Punisher - Punisher hurts you where it hurts most - your time.


Punisher hurts you where it hurts most - your time.

noisy - Don't chat quietly (weechat channel noises)


Don't chat quietly (weechat channel noises)

newlisp-manual - Asciidoc version of the newLISP manual


Asciidoc version of the newLISP manual

Land-of-newLISP - Selected snippets from Land of Lisp rewritten in newLISP


Selected snippets from Land of Lisp rewritten in newLISP

Fossilise - Poor man's collaborative editing in Vim


Poor man's collaborative editing in Vim

firstly - Convert Between Numeric, Spelt, and Short & Long Ordinal Forms of Numbers


Convert Between Numeric, Spelt, and Short & Long Ordinal Forms of Numbers