This package provides extensions to the core "spac" library which allow for the handling of XML data.
This package provides extensions to the core "spac" library which allow for the handling of XML data.
Rather than creating explicit classes that extend Parser
, Transformer
, and Splitter
,
this package provides type aliases and implicit extensions.
For example, XmlParser[A]
is just a type alias for Parser[XmlEvent, A]
,
and XmlParser
is just a call to Parser[XmlEvent]
.
Three main Parser methods are added to Parser[XmlEvent]
via the XmlParserApplyOps
implicit class:
XmlParser.forText
- for capturing raw textXmlParser.attr
- for capturing mandatory attributes from elementsXmlParser.attrOpt
- for capturing optional attributes from elementsOne main Splitter constructor method is added to Splitter
via the XmlSplitterApplyOps
implicit class:
Splitter.xml
- for creating splitters based on an inspection of an "element stack"Three main Splitter member methods are added to Splitter[XmlEvent, C]
via the XmlSplitterOps
implicit class:
.attr
- alias for .joinBy(XmlParser.attr(...))
.attrOpt
- alias for .joinBy(XmlParser.attrOpt(...))
.text
- alias for .joinBy(XmlParser.forText)
A DSL for creating xml-specific ContextMatchers is provided to make it more convenient to call Splitter.xml
.
For example:
Splitter.xml("things" \ "thing").attr("foo").parseToList
Can be used to capture a list of the "foo" attributes in the <thing>
elements in
<things> <thing foo="hello" /> <thing foo="Goodbye"> <extra>junk</extra> </thing> </thing>