Posted to tcl by hypnotoad at Wed Jun 26 16:32:36 GMT 2019view raw

  1. package require cuneiform
  2.  
  3. ::cuneiform::document.xml create XML xml
  4. set root [XML tag playlist]
  5. foreach {name album songtitle} {
  6. {Tom Petty} {Full Moon Fever} {Running Down a Dream}
  7. {Nine Inch Nails} {Pretty Hate Machine} {Head like a Hole}
  8. } {
  9. set record [$root tag song]
  10. $record tag artist $name
  11. $record tag album $album
  12. $record tag title $songtitle
  13. $record tag uuid [clay::uuid::generate]
  14. }
  15.  
  16. set fout [open test.xml w]
  17. puts $fout [XML xml_output]
  18. close $fout
  19.  
  20. ----- OUTPUT -----
  21. <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
  22. <playlist><song><artist>Tom Petty</artist>
  23. <album>Full Moon Fever</album>
  24. <songtitle>Running Down a Dream</songtitle>
  25. <uuid>bc0f1a05-14c4-a1d8-0e47-f90c08926777</uuid>
  26. </song>
  27. <song><artist>Nine Inch Nails</artist>
  28. <album>Pretty Hate Machine</album>
  29. <songtitle>Head like a Hole</songtitle>
  30. <uuid>c65c6435-3ce4-c9d2-2c46-d5408f4a37d4</uuid>
  31. </song>
  32. </playlist>