Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 735 Bytes

Normalize.md

File metadata and controls

29 lines (22 loc) · 735 Bytes

Normalize

Normalization feature allows to collapse empty nodes and trim texts.

We can use directly XmlNormalizer or importing advxml.syntax.* you can have normalization methods onto NodeSeq instance.

Example

import advxml.transform.XmlNormalizer
import scala.xml.{Elem, NodeSeq}

val elem: Elem = <bar><foo></foo></bar>
// elem: Elem = <bar><foo></foo></bar>
val result: NodeSeq = XmlNormalizer.normalize(elem)
// result: NodeSeq = <bar><foo/></bar>

Example with syntax

import scala.xml.{Elem, NodeSeq}
import advxml.implicits.*

val elem: Elem = <bar><foo></foo></bar>
// elem: Elem = <bar><foo></foo></bar>
val result:NodeSeq = elem.normalize
// result: NodeSeq = <bar><foo/></bar>