XML/Output: Difference between revisions

From Rosetta Code
< XML
Content added Content deleted
(New page: {{task}} Given the list of names and the below template, generate an XML document. <Students> <Student Name="XXX" /> </Students> =={{header|Visual Basic .NET}}== Dim names As ...)
 
No edit summary
Line 3: Line 3:
Given the list of names and the below template, generate an XML document.
Given the list of names and the below template, generate an XML document.


<Students>
<Students>
<Student Name="XXX" />
<Student Name="XXX" />
</Students>
</Students>


=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==

Revision as of 11:07, 25 December 2008

Task
XML/Output
You are encouraged to solve this task according to the task description, using any language you may know.

Given the list of names and the below template, generate an XML document.

<Students>
  <Student Name="XXX" />
</Students>

Visual Basic .NET

       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)

Output

<Students>
  <Student Name="April" />
  <Student Name="Bob" />
  <Student Name="Chad" />
  <Student Name="Dave" />
  <Student Name="Emily" />
</Students>