Jump to content

XML/Input: Difference between revisions

→‎{{header|Wren}}: Added a version using an XML library.
m (→‎{{header|Phix}}: syntax coloured)
(→‎{{header|Wren}}: Added a version using an XML library.)
Line 3,506:
Émily
</pre>
<br>
{{libheader|Wren-xsequence}}
Since the first version was written, the above XML parser has appeared and support for 'raw' strings has also been added to the language. Consequently, the solution can now be rewritten as follows, the output being the same as before.
<lang ecmascript>import "./xsequence" for XDocument
 
var xml = """
<Students>
<Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
<Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
<Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" />
<Student Name="Dave" Gender="M" DateOfBirth="1992-07-08">
<Pet Type="dog" Name="Rover" />
</Student>
<Student DateOfBirth="1993-09-10" Gender="F" Name="&#x00C9;mily" />
</Students>
"""
var doc = XDocument.parse(xml)
var names = doc.root.elements("Student").map { |el| el.attribute("Name").value }.toList
System.print(names.join("\n"))</lang>
 
=={{header|XPL0}}==
9,488

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.