Posted to tcl by de at Tue Feb 13 23:54:43 GMT 2018view raw
- tDOM::pullparser pp
- pp input {<doc><e1 a="b" foo:bar="c"><e2>foo</e2><e2></e2></e1><e1/></doc>}
- puts [pp state]
- while {[set state [pp next]] ne "END_DOKUMENT"} {
- puts -nonewline "$state "
- switch $state {
- "START_TAG" {
- puts [pp tag]
- foreach {attname attvalue} [pp attributes] {
- puts "\t$attname -> $attvalue"
- }
- }
- "TEXT" {
- puts [pp text]
- }
- "END_TAG" {
- puts [pp tag]
- }
- }
- }
- pp delete
- START_DOKUMENT
- START_TAG doc
- START_TAG e1
- a -> b
- foo:bar -> c
- START_TAG e2
- TEXT foo
- END_TAG e2
- START_TAG e2
- END_TAG e2
- END_TAG e1
- END_TAG e1
- END_TAG doc
- END_DOKUMENT