File: idtest.rb

package info (click to toggle)
libxml-parser-ruby 0.6.1-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 676 kB
  • ctags: 800
  • sloc: ruby: 5,723; ansic: 1,734; xml: 574; makefile: 152
file content (21 lines) | stat: -rwxr-xr-x 381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/local/bin/ruby

require 'xmlextparser'

if XML::Parser.expatVersion != "1.2"
  raise "This program work with expat-1.2"
end

p = XML::ExtParser.new

def p.startElement(name, attr)
  idattr =  getIdAttribute
  idvalue = idattr ? attr[idattr] : nil;
  printf("%s: ID=(%s:%s)\n", name, idattr, idvalue)
end

begin
  p.parse($<.read)
rescue XMLParserError
  p [$!, p.line]
end