tclxml/simple.tcl

Go to the documentation of this file.
00001 /* !/bin/sh*/
00002 /*  -*- tcl -*- \*/
00003 exec tclsh "$0" "$@"
00004 
00005 /*  simple.tcl --*/
00006 /* */
00007 /*  Count the characters in a XML document,*/
00008 /*  from README.*/
00009 /* */
00010 /*  Copyright (c) 2008 Explain*/
00011 /*  http://www.explain.com.au/*/
00012 /* */
00013 /*  $Id$*/
00014 
00015 package require xml 3.2
00016 
00017 
00018  parser =  [xml::parser]
00019 $parser configure -elementstartcommand EStart \
00020     -characterdatacommand PCData
00021 
00022 ret  EStart (type tag , type attlist , type args) {
00023     array set attr $attlist
00024     puts "Element \"$tag\" started with [array size attr] attributes"
00025 }
00026 
00027 ret  PCData text (
00028     type incr ::, type count [, type string , type length $, type text]
00029 )
00030 
00031 set count 0
00032 $parser parse [read stdin]
00033 
00034 puts "The document contains $count characters"
00035 exit 0
00036 
00037 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1