From 97decea4eb174a9313f30c629a1afb42646d144b Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Wed, 20 Feb 2013 13:11:03 +0100 Subject: Add missing parser_list argument to sax.make_parser() The argument is ignored, though. (thanks to Florian Apolloner) --- other/README.txt | 3 +++ other/perl.pl | 9 +++++++++ other/php.php | 13 +++++++++++++ other/python-genshi.py | 9 +++++++++ other/ruby-hpricot.rb | 7 +++++++ other/ruby-libxml.rb | 17 +++++++++++++++++ other/ruby-rexml.rb | 9 +++++++++ 7 files changed, 67 insertions(+) create mode 100644 other/README.txt create mode 100755 other/perl.pl create mode 100755 other/php.php create mode 100755 other/python-genshi.py create mode 100755 other/ruby-hpricot.rb create mode 100755 other/ruby-libxml.rb create mode 100755 other/ruby-rexml.rb (limited to 'other') diff --git a/other/README.txt b/other/README.txt new file mode 100644 index 0000000..3d58b0f --- /dev/null +++ b/other/README.txt @@ -0,0 +1,3 @@ +This directory contains test and demo scripts for other frameworks and +languages. I used them to examine the characteristics of XML parsers. + diff --git a/other/perl.pl b/other/perl.pl new file mode 100755 index 0000000..00e8249 --- /dev/null +++ b/other/perl.pl @@ -0,0 +1,9 @@ +#!/usr/bin/perl + +use XML::Simple; +use Data::Dumper; + +$parser = new XML::Simple; +$xml = $parser->XMLin("$ARGV[0]"); +$data = Dumper($xml); +print $data; diff --git a/other/php.php b/other/php.php new file mode 100755 index 0000000..e35665b --- /dev/null +++ b/other/php.php @@ -0,0 +1,13 @@ +#!/usr/bin/php + + diff --git a/other/python-genshi.py b/other/python-genshi.py new file mode 100755 index 0000000..183d1fe --- /dev/null +++ b/other/python-genshi.py @@ -0,0 +1,9 @@ +#!/usr/bin/python +import sys +from pprint import pprint +from genshi.input import XMLParser + +with open(sys.argv[1]) as f: + parser = XMLParser(f) + pprint(list(parser)) + diff --git a/other/ruby-hpricot.rb b/other/ruby-hpricot.rb new file mode 100755 index 0000000..4f47b93 --- /dev/null +++ b/other/ruby-hpricot.rb @@ -0,0 +1,7 @@ +#!/usr/bin/ruby -w +require 'hpricot' + +xml = File.read(ARGV[0]) +doc = Hpricot(xml) +puts doc + diff --git a/other/ruby-libxml.rb b/other/ruby-libxml.rb new file mode 100755 index 0000000..b4af2dd --- /dev/null +++ b/other/ruby-libxml.rb @@ -0,0 +1,17 @@ +#!/usr/bin/ruby -w +require 'libxml' + +include LibXML + +class PostCallbacks + include XML::SaxParser::Callbacks + + def on_start_element(element, attributes) + puts element + end +end + +parser = XML::SaxParser.file(ARGV[0]) +parser.callbacks = PostCallbacks.new +parser.parse + diff --git a/other/ruby-rexml.rb b/other/ruby-rexml.rb new file mode 100755 index 0000000..31727d1 --- /dev/null +++ b/other/ruby-rexml.rb @@ -0,0 +1,9 @@ +#!/usr/bin/ruby -w +require "rexml/document" + +xml = File.read(ARGV[0]) +# REXML::Document.entity_expansion_limit = 1000 +xmldoc = REXML::Document.new(xml) +data = xmldoc.root.text +#puts data.length +puts data -- cgit v1.2.1