RosettaCodeData/Task/XML-Output/Tcl/xml-output-1.tcl
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

28 lines
742 B
Tcl

proc xquote string {
list [string map "' &apos; \\\" &quot; < &gt; > &lt; & &amp;" $string]
}
proc < {name attl args} {
set res <$name
foreach {att val} $attl {
append res " $att='$val'"
}
if {[llength $args]} {
append res >
set sep ""
foreach a $args {
append res $sep $a
set sep \n
}
append res </$name>
} else {append res />}
return $res
}
set cmd {< CharacterRemarks {}}
foreach {name comment} {
April "Bubbly: I'm > Tam and <= Emily"
"Tam O'Shanter" "Burns: \"When chapman billies leave the street ...\""
Emily "Short & shrift"
} {
append cmd " \[< Character {Name [xquote $name]} [xquote $comment]\]"
}
puts [eval $cmd]