Packages

  • package root
    Definition Classes
    root
  • package scala
    Definition Classes
    root
  • package xml

    This library provides support for the XML literal syntax in Scala programs.

    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.

    A less greedy XML reader can return data as a sequential collection of events, see scala.xml.pull.XMLEventReader.

    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.

    Definition Classes
    scala
  • package pull

    Classes needed to view an XML document as a series of events.

    Classes needed to view an XML document as a series of events. The document is parsed by an scala.xml.pull.XMLEventReader instance. You can treat it as an scala.collection.Iterator to retrieve the events, which are all subclasses of scala.xml.pull.XMLEvent.

    scala> val source = Source.fromString("""<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <?instruction custom value="customvalue"?>
    <!DOCTYPE foo [
      <!ENTITY bar "BAR">
    ]><foo>Hello<bar>&bar;</bar><bar>></bar></foo>""")
    
    source: scala.io.Source = non-empty iterator
    
    scala> val reader = new XMLEventReader(source)
    reader: scala.xml.pull.XMLEventReader = non-empty iterator
    
    scala> reader.foreach{ println(_) }
    EvProcInstr(instruction,custom value="customvalue")
    EvText(
    )
    EvElemStart(null,foo,,)
    EvText(Hello)
    EvComment( this is a comment )
    EvElemStart(null,bar,,)
    EvText(BAR)
    EvElemEnd(null,bar)
    EvElemStart(null,bar,,)
    EvEntityRef(gt)
    EvElemEnd(null,bar)
    EvElemEnd(null,foo)
    EvText(
    
    )
    Definition Classes
    xml
  • EvComment
  • EvElemEnd
  • EvElemStart
  • EvEntityRef
  • EvProcInstr
  • EvText
  • ProducerConsumerIterator
  • XMLEvent
  • XMLEventReader
c

scala.xml.pull

XMLEventReader

class XMLEventReader extends AbstractIterator[XMLEvent] with ProducerConsumerIterator[XMLEvent]

Main entry point into creating an event-based XML parser. Treating this as a scala.collection.Iterator will provide access to the generated events.

Annotations
@deprecated
Deprecated

(Since version 1.1.1) Consider javax.xml.stream.XMLEventReader instead.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. XMLEventReader
  2. ProducerConsumerIterator
  3. AbstractIterator
  4. Iterator
  5. IterableOnceOps
  6. IterableOnce
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new XMLEventReader(src: Source)

    src

    A scala.io.Source for XML data to parse

Type Members

  1. class GroupedIterator[B >: A] extends AbstractIterator[collection.immutable.Seq[B]]
    Definition Classes
    Iterator

Value Members

  1. final def ++[B >: XMLEvent](xs: => collection.IterableOnce[B]): collection.Iterator[B]
    Definition Classes
    Iterator
    Annotations
    @inline()
  2. val EndOfStream: POISON
  3. val MaxQueueSize: Int
  4. final def addString(b: collection.mutable.StringBuilder): collection.mutable.StringBuilder
    Definition Classes
    IterableOnceOps
    Annotations
    @inline()
  5. final def addString(b: collection.mutable.StringBuilder, sep: String): collection.mutable.StringBuilder
    Definition Classes
    IterableOnceOps
    Annotations
    @inline()
  6. def addString(b: collection.mutable.StringBuilder, start: String, sep: String, end: String): collection.mutable.StringBuilder
    Definition Classes
    IterableOnceOps
  7. def available(): Boolean
    Definition Classes
    ProducerConsumerIterator
  8. def buffered: collection.BufferedIterator[XMLEvent]
    Definition Classes
    Iterator
  9. def collect[B](pf: PartialFunction[XMLEvent, B]): collection.Iterator[B]
    Definition Classes
    Iterator → IterableOnceOps
  10. def collectFirst[B](pf: PartialFunction[XMLEvent, B]): Option[B]
    Definition Classes
    IterableOnceOps
  11. def concat[B >: XMLEvent](xs: => collection.IterableOnce[B]): collection.Iterator[B]
    Definition Classes
    Iterator
  12. def contains(elem: Any): Boolean
    Definition Classes
    Iterator
  13. def copyToArray[B >: XMLEvent](xs: Array[B], start: Int, len: Int): Int
    Definition Classes
    IterableOnceOps
  14. def copyToArray[B >: XMLEvent](xs: Array[B], start: Int): Int
    Definition Classes
    IterableOnceOps
  15. def copyToArray[B >: XMLEvent](xs: Array[B]): Int
    Definition Classes
    IterableOnceOps
  16. def corresponds[B](that: collection.IterableOnce[B])(p: (XMLEvent, B) => Boolean): Boolean
    Definition Classes
    IterableOnceOps
  17. def count(p: (XMLEvent) => Boolean): Int
    Definition Classes
    IterableOnceOps
  18. def distinct: collection.Iterator[XMLEvent]
    Definition Classes
    Iterator
  19. def distinctBy[B](f: (XMLEvent) => B): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator
  20. def drop(n: Int): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  21. def dropWhile(p: (XMLEvent) => Boolean): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  22. def duplicate: (collection.Iterator[XMLEvent], collection.Iterator[XMLEvent])
    Definition Classes
    Iterator
  23. def exists(p: (XMLEvent) => Boolean): Boolean
    Definition Classes
    IterableOnceOps
  24. def filter(p: (XMLEvent) => Boolean): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  25. def filterNot(p: (XMLEvent) => Boolean): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  26. def find(p: (XMLEvent) => Boolean): Option[XMLEvent]
    Definition Classes
    IterableOnceOps
  27. def flatMap[B](f: (XMLEvent) => collection.IterableOnce[B]): collection.Iterator[B]
    Definition Classes
    Iterator → IterableOnceOps
  28. def flatten[B](implicit ev: (XMLEvent) => collection.IterableOnce[B]): collection.Iterator[B]
    Definition Classes
    Iterator → IterableOnceOps
  29. def fold[A1 >: XMLEvent](z: A1)(op: (A1, A1) => A1): A1
    Definition Classes
    IterableOnceOps
  30. def foldLeft[B](z: B)(op: (B, XMLEvent) => B): B
    Definition Classes
    IterableOnceOps
  31. def foldRight[B](z: B)(op: (XMLEvent, B) => B): B
    Definition Classes
    IterableOnceOps
  32. def forall(p: (XMLEvent) => Boolean): Boolean
    Definition Classes
    IterableOnceOps
  33. def foreach[U](f: (XMLEvent) => U): Unit
    Definition Classes
    IterableOnceOps
  34. def grouped[B >: XMLEvent](size: Int): GroupedIterator[B]
    Definition Classes
    Iterator
  35. def hasNext: Boolean
    Definition Classes
    ProducerConsumerIterator → Iterator
  36. def indexOf[B >: XMLEvent](elem: B, from: Int): Int
    Definition Classes
    Iterator
  37. def indexOf[B >: XMLEvent](elem: B): Int
    Definition Classes
    Iterator
  38. def indexWhere(p: (XMLEvent) => Boolean, from: Int): Int
    Definition Classes
    Iterator
  39. def interruptibly[A](body: => A): Option[A]
    Definition Classes
    ProducerConsumerIterator
  40. def isEmpty: Boolean
    Definition Classes
    Iterator → IterableOnceOps
    Annotations
    @deprecatedOverriding("isEmpty is defined as !hasNext; override hasNext instead", "2.13.0")
  41. def isTraversableAgain: Boolean
    Definition Classes
    IterableOnceOps
  42. final def iterator: collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnce
    Annotations
    @inline()
  43. def knownSize: Int
    Definition Classes
    IterableOnce
  44. final def length: Int
    Definition Classes
    Iterator
    Annotations
    @inline()
  45. def map[B](f: (XMLEvent) => B): collection.Iterator[B]
    Definition Classes
    Iterator → IterableOnceOps
  46. def max[B >: XMLEvent](implicit ord: math.Ordering[B]): XMLEvent
    Definition Classes
    IterableOnceOps
  47. def maxBy[B](f: (XMLEvent) => B)(implicit cmp: math.Ordering[B]): XMLEvent
    Definition Classes
    IterableOnceOps
  48. def maxByOption[B](f: (XMLEvent) => B)(implicit cmp: math.Ordering[B]): Option[XMLEvent]
    Definition Classes
    IterableOnceOps
  49. def maxOption[B >: XMLEvent](implicit ord: math.Ordering[B]): Option[XMLEvent]
    Definition Classes
    IterableOnceOps
  50. def min[B >: XMLEvent](implicit ord: math.Ordering[B]): XMLEvent
    Definition Classes
    IterableOnceOps
  51. def minBy[B](f: (XMLEvent) => B)(implicit cmp: math.Ordering[B]): XMLEvent
    Definition Classes
    IterableOnceOps
  52. def minByOption[B](f: (XMLEvent) => B)(implicit cmp: math.Ordering[B]): Option[XMLEvent]
    Definition Classes
    IterableOnceOps
  53. def minOption[B >: XMLEvent](implicit ord: math.Ordering[B]): Option[XMLEvent]
    Definition Classes
    IterableOnceOps
  54. final def mkString: String
    Definition Classes
    IterableOnceOps
    Annotations
    @inline()
  55. final def mkString(sep: String): String
    Definition Classes
    IterableOnceOps
    Annotations
    @inline()
  56. final def mkString(start: String, sep: String, end: String): String
    Definition Classes
    IterableOnceOps
  57. def next(): XMLEvent
    Definition Classes
    ProducerConsumerIterator → Iterator
  58. def nextOption(): Option[XMLEvent]
    Definition Classes
    Iterator
  59. def nonEmpty: Boolean
    Definition Classes
    IterableOnceOps
    Annotations
    @deprecatedOverriding("nonEmpty is defined as !isEmpty; override isEmpty instead", "2.13.0")
  60. def padTo[B >: XMLEvent](len: Int, elem: B): collection.Iterator[B]
    Definition Classes
    Iterator
  61. def partition(p: (XMLEvent) => Boolean): (collection.Iterator[XMLEvent], collection.Iterator[XMLEvent])
    Definition Classes
    Iterator
  62. def patch[B >: XMLEvent](from: Int, patchElems: collection.Iterator[B], replaced: Int): collection.Iterator[B]
    Definition Classes
    Iterator
  63. val preserveWS: Boolean
  64. def produce(x: XMLEvent): Unit
    Definition Classes
    ProducerConsumerIterator
  65. def product[B >: XMLEvent](implicit num: math.Numeric[B]): B
    Definition Classes
    IterableOnceOps
  66. def reduce[B >: XMLEvent](op: (B, B) => B): B
    Definition Classes
    IterableOnceOps
  67. def reduceLeft[B >: XMLEvent](op: (B, XMLEvent) => B): B
    Definition Classes
    IterableOnceOps
  68. def reduceLeftOption[B >: XMLEvent](op: (B, XMLEvent) => B): Option[B]
    Definition Classes
    IterableOnceOps
  69. def reduceOption[B >: XMLEvent](op: (B, B) => B): Option[B]
    Definition Classes
    IterableOnceOps
  70. def reduceRight[B >: XMLEvent](op: (XMLEvent, B) => B): B
    Definition Classes
    IterableOnceOps
  71. def reduceRightOption[B >: XMLEvent](op: (XMLEvent, B) => B): Option[B]
    Definition Classes
    IterableOnceOps
  72. def sameElements[B >: XMLEvent](that: collection.IterableOnce[B]): Boolean
    Definition Classes
    Iterator
  73. def scanLeft[B](z: B)(op: (B, XMLEvent) => B): collection.Iterator[B]
    Definition Classes
    Iterator → IterableOnceOps
  74. def size: Int
    Definition Classes
    IterableOnceOps
  75. def slice(from: Int, until: Int): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  76. def sliding[B >: XMLEvent](size: Int, step: Int): GroupedIterator[B]
    Definition Classes
    Iterator
  77. def span(p: (XMLEvent) => Boolean): (collection.Iterator[XMLEvent], collection.Iterator[XMLEvent])
    Definition Classes
    Iterator → IterableOnceOps
  78. def splitAt(n: Int): (collection.Iterator[XMLEvent], collection.Iterator[XMLEvent])
    Definition Classes
    IterableOnceOps
  79. def stepper[S <: Stepper[_]](implicit shape: StepperShape[XMLEvent, S]): S
    Definition Classes
    IterableOnce
  80. def stop(): Unit
  81. def sum[B >: XMLEvent](implicit num: math.Numeric[B]): B
    Definition Classes
    IterableOnceOps
  82. def take(n: Int): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  83. def takeWhile(p: (XMLEvent) => Boolean): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  84. def tapEach[U](f: (XMLEvent) => U): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator → IterableOnceOps
  85. def to[C1](factory: Factory[XMLEvent, C1]): C1
    Definition Classes
    IterableOnceOps
  86. def toArray[B >: XMLEvent](implicit arg0: ClassTag[B]): Array[B]
    Definition Classes
    IterableOnceOps
  87. final def toBuffer[B >: XMLEvent]: Buffer[B]
    Definition Classes
    IterableOnceOps
    Annotations
    @inline()
  88. def toIndexedSeq: collection.immutable.IndexedSeq[XMLEvent]
    Definition Classes
    IterableOnceOps
  89. def toList: collection.immutable.List[XMLEvent]
    Definition Classes
    IterableOnceOps
  90. def toMap[K, V](implicit ev: <:<[XMLEvent, (K, V)]): Map[K, V]
    Definition Classes
    IterableOnceOps
  91. def toSeq: collection.immutable.Seq[XMLEvent]
    Definition Classes
    IterableOnceOps
  92. def toSet[B >: XMLEvent]: Set[B]
    Definition Classes
    IterableOnceOps
  93. def toString(): String
    Definition Classes
    Iterator → AnyRef → Any
  94. def toVector: collection.immutable.Vector[XMLEvent]
    Definition Classes
    IterableOnceOps
  95. def withFilter(p: (XMLEvent) => Boolean): collection.Iterator[XMLEvent]
    Definition Classes
    Iterator
  96. def zip[B](that: collection.IterableOnce[B]): collection.Iterator[(XMLEvent, B)]
    Definition Classes
    Iterator
  97. def zipAll[A1 >: XMLEvent, B](that: collection.IterableOnce[B], thisElem: A1, thatElem: B): collection.Iterator[(A1, B)]
    Definition Classes
    Iterator
  98. def zipWithIndex: collection.Iterator[(XMLEvent, Int)]
    Definition Classes
    Iterator → IterableOnceOps

Deprecated Value Members

  1. final def /:[B](z: B)(op: (B, XMLEvent) => B): B
    Definition Classes
    IterableOnceOps
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use foldLeft instead of /:

  2. final def :\[B](z: B)(op: (XMLEvent, B) => B): B
    Definition Classes
    IterableOnceOps
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use foldRight instead of :\

  3. def aggregate[B](z: => B)(seqop: (B, XMLEvent) => B, combop: (B, B) => B): B
    Definition Classes
    IterableOnceOps
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) aggregate is not relevant for sequential collections. Use foldLeft(z)(seqop) instead.

  4. final def copyToBuffer[B >: XMLEvent](dest: Buffer[B]): Unit
    Definition Classes
    IterableOnceOps
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use dest ++= coll instead

  5. final def hasDefiniteSize: Boolean
    Definition Classes
    Iterator → IterableOnceOps
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) hasDefiniteSize on Iterator is the same as isEmpty

  6. def scanRight[B](z: B)(op: (XMLEvent, B) => B): collection.Iterator[B]
    Definition Classes
    Iterator
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Call scanRight on an Iterable instead.

  7. def seq: XMLEventReader.this.type
    Definition Classes
    Iterator
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Iterator.seq always returns the iterator itself

  8. final def toIterator: collection.Iterator[XMLEvent]
    Definition Classes
    IterableOnceOps
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use .iterator instead of .toIterator

  9. final def toStream: collection.immutable.Stream[XMLEvent]
    Definition Classes
    IterableOnceOps
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.13.0) Use .to(LazyList) instead of .toStream