XML/Output
< XML
foreach XXX {April Bob Chad Dave Emily O'Connor} {
XML/Output
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
append cmd " \[< Student {Name $XXX}\]"
} puts [eval $cmd]</lang>
produces
<Students> <Student Name='April'/> <Student Name='Bob'/> <Student Name='Chad'/> <Student Name='Dave'/> <Student Name='Emily'/> <Student Name='O'Connor'/></Students>
Using
<lang tcl>package require tdom set xml [dom createDocument Students] foreach name {April Bob Chad Dave Emily} {
set element [$xml createElement Student] $element setAttribute Name $name [$xml documentElement] appendChild $element
} $xml asXML</lang>
<Students> <Student Name="April"/> <Student Name="Bob"/> <Student Name="Chad"/> <Student Name="Dave"/> <Student Name="Emily"/> </Students>
Using
<lang tcl>package require dom set xml [dom::DOMImplementation create] set root [dom::document createElement $xml Students] foreach name {April Bob Chad Dave Emily} {
set element [dom::document createElement $root Student] dom::element setAttribute $element Name $name
} dom::DOMImplementation serialize $xml</lang>
<?xml version='1.0'?> <!DOCTYPE Students> <Students><Student Name="April"/><Student Name="Bob"/><Student Name="Chad"/><Student Name="Dave"/><Student Name="Emily"/></Students>
Visual Basic .NET
<lang vbnet>Dim names As String() = New String() {"April", "Bob", "Chad", "Dave", "Emily"}
Dim xml = <Students>
<%= From s In names Select <Student Name=<%= s %>/> %> </Students>
Console.WriteLine(xml)</lang>