package xml
This library provides support for the XML literal syntax in Scala programs.
val planets: scala.xml.Elem = <planets> <planet id="earth"> <title>Earth</title> <mass unit="kg">5.9742e24</mass> <radius unit="m">6378.14e3</radius> </planet> <planet id="mars"> <title>Mars</title> <mass unit="kg">0.64191e24</mass> <radius unit="m">3397.0e3</radius> </planet> </planets>
Additionally, you can mix Scala expressions in your XML elements by using the curly brace notation:
val sunMass = 1.99e30 val sunRadius = 6.96e8 val star = <star> <title>Sun</title> <mass unit="kg">{ sunMass }</mass> <radius unit="m">{ sunRadius }</radius> <surface unit="m²">{ 4 * Math.PI * Math.pow(sunRadius, 2) }</surface> <volume unit="m³">{ 4/3 * Math.PI * Math.pow(sunRadius, 3) }</volume> </star>
An XML element, for example <star/> and <planet/>, is
represented in this library as a case class, scala.xml.Elem.
The sub-elements of XML values share a common base class, scala.xml.Node.
However, the non-element declarations found in XML files share a different common base class, scala.xml.dtd.Decl. Additionally, document type declarations are represented by a different trait, scala.xml.dtd.DTD.
For reading and writing XML data to and from files, see scala.xml.XML. The default parser of XML data is the Xerces parser and is provided in Java by javax.xml.parsers.SAXParser.
For more control of the input, use the parser written in Scala that is provided, scala.xml.parsing.ConstructingParser.
For working with XHTML input, use scala.xml.parsing.XhtmlParser.
For more control of the output, use the scala.xml.PrettyPrinter.
Utility methods for working with XML data are provided in scala.xml.Utility.
XML values in Scala are immutable, but you can traverse and transform XML data with a scala.xml.transform.RuleTransformer.
- Alphabetic
- By Inheritance
- xml
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
Type Members
-    class Atom[+A] extends SpecialNode with SerializableThe class Atomprovides an XML node for text (PCDATA).The class Atomprovides an XML node for text (PCDATA). It is used in both non-bound and bound XML representations.
-    trait Attribute extends MetaDataThe Attributetrait defines the interface shared by both scala.xml.PrefixedAttribute and scala.xml.UnprefixedAttribute.
-    case class Comment(commentText: String) extends SpecialNode with Product with SerializableThe class Commentimplements an XML node for comments.The class Commentimplements an XML node for comments.- commentText
- the text contained in this node, may not contain "--" and the final character may not be - -to prevent a closing span of- -->which is invalid. https://www.w3.org/TR/xml11//#IDA5CES
 
-    class Document extends NodeSeq with SerializableA document information item (according to InfoSet spec). A document information item (according to InfoSet spec). The comments are copied from the Infoset spec, only augmented with some information on the Scala types for definitions that might have no value. Also plays the role of an XMLEventfor pull parsing.- Annotations
- @SerialVersionUID()
 
-    class Elem extends Node with SerializableAn immutable data object representing an XML element. An immutable data object representing an XML element. Child elements can be other Elems or any one of the other Node types. XML attributes are implemented with the scala.xml.MetaData base class. Optional XML namespace scope is represented by scala.xml.NamespaceBinding. 
-    case class EntityRef(entityName: String) extends SpecialNode with Product with SerializableThe class EntityRefimplements an XML node for entity references.The class EntityRefimplements an XML node for entity references.- entityName
- the name of the entity reference, for example - amp.
 
-  type EntityResolver = org.xml.sax.EntityResolver
-  trait Equality extends Equals
-   final  case class Group(nodes: collection.Seq[Node]) extends Node with Product with SerializableA hack to group XML nodes in one node for output. 
-  type InputSource = org.xml.sax.InputSource
-  case class MalformedAttributeException(msg: String) extends RuntimeException with Product with Serializable
-   abstract  class MetaData extends AbstractIterable[MetaData] with Iterable[MetaData] with Equality with SerializableThis class represents an attribute and at the same time a linked list of attributes. This class represents an attribute and at the same time a linked list of attributes. Every instance of this class is either - an instance of UnprefixedAttribute key,valueor
- an instance of PrefixedAttribute namespace_prefix,key,valueor
- Null, the empty attribute list.
 Namespace URIs are obtained by using the namespace scope of the element owning this attribute (see getNamespace).
- an instance of 
-    case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBinding) extends Equality with Product with SerializableThe class NamespaceBindingrepresents namespace bindings and scopes.The class NamespaceBindingrepresents namespace bindings and scopes. The binding for the default namespace is treated as a null prefix. the absent namespace is represented with the null uri. Neither prefix nor uri may be empty, which is not checked.- Annotations
- @SerialVersionUID()
 
-   abstract  class Node extends NodeSeqAn abstract class representing XML with nodes of a labeled tree. An abstract class representing XML with nodes of a labeled tree. This class contains an implementation of a subset of XPath for navigation. - scala.xml.Comment — XML comment
- scala.xml.Elem — XML element
- scala.xml.EntityRef — XML entity
- scala.xml.PCData — Character data section (CDATA)
- scala.xml.ProcInstr — Processing instruction (PI)
- scala.xml.Text — Stand-alone parsed character data
 
-    class NodeBuffer extends ArrayBuffer[Node] with ScalaVersionSpecificNodeBufferThis class acts as a Buffer for nodes. This class acts as a Buffer for nodes. If it is used as a sequence of nodes Seq[Node], it must be ensured that no updates occur after that point, becausescala.xml.Nodeis assumed to be immutable.Despite this being a sequence, don't use it as key in a hashtable. Calling the hashcode function will result in a runtime error. 
-   abstract  class NodeSeq extends AbstractSeq[Node] with collection.immutable.Seq[Node] with ScalaVersionSpecificNodeSeq with Equality with SerializableThis class implements a wrapper around Seq[Node]that adds XPath and comprehension methods.
-    class PCData extends Atom[String]This class (which is not used by all XML parsers, but always used by the XHTML one) represents parseable character data, which appeared as CDATA sections in the input and is to be preserved as CDATA section in the output. 
-    class PrefixedAttribute extends MetaData with Attributeprefixed attributes always have a non-null namespace. 
-    class PrettyPrinter extends AnyRefClass for pretty printing. Class for pretty printing. After instantiating, you can use the format() and formatNode() methods to convert XML to a formatted string. The class can be reused to pretty print any number of XML nodes. - Note
- This class is not threadsafe and should not be accessed by multiple threads at the same time. 
 
-    case class ProcInstr(target: String, proctext: String) extends SpecialNode with Product with Serializablean XML node for processing instructions (PI) an XML node for processing instructions (PI) - target
- target name of this PI 
- proctext
- text contained in this node, may not contain "?>" 
 
-  type SAXException = org.xml.sax.SAXException
-  type SAXParseException = org.xml.sax.SAXParseException
-  type SAXParser = javax.xml.parsers.SAXParser
-   abstract  class SpecialNode extends NodeSpecialNodeis a special XML node which represents either text(PCDATA), a comment, aPI, or an entity ref.
-    class Text extends Atom[String]The class Textimplements an XML node for text (PCDATA).The class Textimplements an XML node for text (PCDATA). It is used in both non-bound and bound XML representations.
-    class TextBuffer extends AnyRefThe class TextBufferis for creating text nodes without surplus whitespace.The class TextBufferis for creating text nodes without surplus whitespace. All occurrences of one or more whitespace in strings appended with theappendmethod will be replaced by a single space character, and leading and trailing space will be removed completely.
-  abstract class TypeSymbol extends AnyRef
-    class Unparsed extends Atom[String]An XML node for unparsed content. An XML node for unparsed content. It will be output verbatim, all bets are off regarding wellformedness etc. 
-    class UnprefixedAttribute extends MetaData with AttributeUnprefixed attributes have the null namespace, and no prefix field 
Value Members
-  val XercesClassName: String
-    object Attribute extends java.io.SerializableThis singleton object contains the applyandunapplymethods for convenient construction and deconstruction.
-    object Elem extends java.io.SerializableThis singleton object contains the applyandunapplySeqmethods for convenient construction and deconstruction.This singleton object contains the applyandunapplySeqmethods for convenient construction and deconstruction. It is possible to deconstruct anyNodeinstance (that is not aSpecialNodeor aGroup) using the syntaxcase Elem(prefix, label, attribs, scope, child @ _*) => ...
-    object EqualityIn an attempt to contain the damage being inflicted on consistency by the ad hoc equalsmethods spread aroundxml, the logic is centralized and all thexmlclasses go through thexml.Equality trait.In an attempt to contain the damage being inflicted on consistency by the ad hoc equalsmethods spread aroundxml, the logic is centralized and all thexmlclasses go through thexml.Equality trait. There are two forms ofxmlcomparison.- def strict_==(other: scala.xml.Equality)
 This one tries to honor the little things like symmetry and hashCode contracts. The equalsmethod routes all comparisons through this.- xml_==(other: Any)
 This one picks up where strict_==leaves off. It might declare any two things equal.As things stood, the logic not only made a mockery of the collections equals contract, but also laid waste to that of case classes. Among the obstacles to sanity are/were: Node extends NodeSeq extends Seq[Node] MetaData extends Iterable[MetaData] The hacky "Group" xml node which throws exceptions with wild abandon, so don't get too close Rampant asymmetry and impossible hashCodes Most classes claiming to be equal to "String" if some specific stringification of it was the same. String was never going to return the favor. 
-  object MetaData extends java.io.Serializable
-    object MinimizeMode extends EnumerationGoverns how empty elements (i.e. Governs how empty elements (i.e. those without child elements) should be serialized. 
-    object Node extends java.io.SerializableThis singleton object contains the unapplySeqmethod for convenient deconstruction.
-    object NodeSeq extends java.io.SerializableThis object ... 
-    case object Null extends MetaData with Product with SerializableEssentially, every method in here is a dummy, returning Zero[T]. Essentially, every method in here is a dummy, returning Zero[T]. It provides a backstop for the unusual collection defined by MetaData, sort of a linked list of tails. 
-    object PCData extends java.io.SerializableThis singleton object contains the applyandunapplymethods for convenient construction and deconstruction.
-  object PrefixedAttribute extends java.io.Serializable
-    object QNodeThis object provides an extractor method to match a qualified node with its namespace URI 
-  object Source
-    object Text extends java.io.SerializableThis singleton object contains the applyandunapplymethods for convenient construction and deconstruction.
-  object TextBuffer
-    object TopScope extends NamespaceBindingtop level namespace scope. top level namespace scope. only contains the predefined binding for the "xml" prefix which is bound to "http://www.w3.org/XML/1998/namespace" 
-    object Unparsed extends java.io.SerializableThis singleton object contains the applyandunapplymethods for convenient construction and deconstruction.
-  object UnprefixedAttribute extends java.io.Serializable
-    object Utility extends TokenTestsThe Utilityobject provides utility functions for processing instances of bound and not bound XML classes, as well as escaping text nodes.
-    object XML extends XMLLoader[Elem]The object XMLprovides constants, and functions to load and save XML elements.The object XMLprovides constants, and functions to load and save XML elements. Use this when data binding is not desired, i.e. when XML is handled usingSymbolnodes.
-  object Xhtml