Posted to tcl by hypnotoad at Wed Jun 26 16:32:36 GMT 2019view raw
- package require cuneiform
- ::cuneiform::document.xml create XML xml
- set root [XML tag playlist]
- foreach {name album songtitle} {
- {Tom Petty} {Full Moon Fever} {Running Down a Dream}
- {Nine Inch Nails} {Pretty Hate Machine} {Head like a Hole}
- } {
- set record [$root tag song]
- $record tag artist $name
- $record tag album $album
- $record tag title $songtitle
- $record tag uuid [clay::uuid::generate]
- }
- set fout [open test.xml w]
- puts $fout [XML xml_output]
- close $fout
- ----- OUTPUT -----
- <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <playlist><song><artist>Tom Petty</artist>
- <album>Full Moon Fever</album>
- <songtitle>Running Down a Dream</songtitle>
- <uuid>bc0f1a05-14c4-a1d8-0e47-f90c08926777</uuid>
- </song>
- <song><artist>Nine Inch Nails</artist>
- <album>Pretty Hate Machine</album>
- <songtitle>Head like a Hole</songtitle>
- <uuid>c65c6435-3ce4-c9d2-2c46-d5408f4a37d4</uuid>
- </song>
- </playlist>