XML/Input: Difference between revisions

From Rosetta Code
< XML
Content added Content deleted
No edit summary
Line 11: Line 11:
</Students>
</Students>


Expected Output

April
Bob
Chad
Dave
Emily


=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
Line 26: Line 33:
Console.WriteLine(name)
Console.WriteLine(name)
Next
Next

Output

April
Bob
Chad
Dave
Emily

Revision as of 11:12, 25 December 2008

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

Given the below XML fragment, extract the list of names.

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

Expected Output

April
Bob
Chad
Dave
Emily

Visual Basic .NET

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

       Dim names = (From node In xml...<Student> Select node.@Name).ToArray

       For Each name In names
           Console.WriteLine(name)
       Next