XML
XML is a value of its own, not text. You move between the two explicitly: xml from text going in, text from xml coming out.
Availability: included in the current release candidate (1.0.0). Whether it is part of the supported Otter 1.0 surface has not been decided yet, so details may change.
Building a document
Otter
catalog is xml with root "library"
library is root of catalog
add element "book" to library and call it book
set attribute "id" of book to "42"
add element "title" with text "Learning Otter" to book
say pretty text from xml catalog
Output
<?xml version="1.0" encoding="utf-8"?>
<library>
<book id="42">
<title>Learning Otter</title>
</book>
</library>
Reading a document
Otter
books is elements "book" in library
say length of books
each b in books
t is text of "title" in b
i is attribute "id" of b
say t
say i
.
first is child 0 in library
say name of first
element finds one direct child by tag name, elements finds all of them, and child N in picks by position. Files: xml from file "books.xml" reads a document and write xml document to file "books.xml" saves one. XML works in console programs and in web applications.
Back to the reference