Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Aaron S. Hawley edited this page Oct 13, 2017 · 2 revisions

The scala-xml library lets you type in XML as a literal anywhere that an expression is valid. Simply type a start tag and then continue writing XML content. The compiler will go into an XML-input mode and will read content as XML until it sees the end tag matching the start tag you began with:

val book = <book id="b20234">Magic of scala-xml</book>

The result of this expression is of type scala.xml.Elem. It is an XML element with a label, of "book".

Some other important XML classes are:

  • scala.xml.Node is the abstract superclass of all XML node classes.
  • scala.xml.Text is a Node holding just text. For example, the "text" part of <tag>text</tag> is of class scala.xml.Text.
  • NodeSeq represents a sequence of Nodes. Many methods in the XML library process NodeSeqs in places you might expect them to process individual Nodes. You can still use such methods with individual Nodes, however, since Node extends from NodeSeq. This recursive structure works out well for XML. You can think of an individual Node as a single-element NodeSeq.
Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /