Skip to main content
The XML dataformat supports reading XML from Strings or input streams.

Reading XML from a String:

The second paramter xml() hints Spin to use the XML data format for parsing the XML. Alternatively, you can directly use the XML(...) function:

Reading XML from a Reader:

Spin also supports reading XML directly from a java.io.Reader:
The XML(...) method also supports readers. The following example shows how to read the XML from a file (error handling ommitted):

Reading XML using a Script Language

XML can be read from script languages in the same way as from Java. Since script languages use dynamic typing, you do not need to hint the data format but you can use autodetection. The following example demonstrates how to read XML in JavaScript: