File: idtest.rb

package info (click to toggle)
libxml-parser-ruby 0.6.8-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 912 kB
  • ctags: 1,523
  • sloc: ruby: 11,080; ansic: 1,958; xml: 467; makefile: 59
file content (21 lines) | stat: -rwxr-xr-x 389 bytes parent folder | download | duplicates (3)
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 XML::Parser::Error
  p([$!, p.line])
end