@@ -19,7 +19,7 @@ package software.purpledragon.xml.compare
1919import software .purpledragon .xml .compare .options .DiffOption ._
2020import software .purpledragon .xml .compare .options .DiffOptions
2121
22- import scala .xml .{Node , Text }
22+ import scala .xml .{Atom , Node }
2323
2424/**
2525 * Utility for comparing XML documents.
@@ -79,8 +79,9 @@ object XmlCompare {
7979 }
8080
8181 private def compareText (left : Node , right : Node , options : DiffOptions , path : Seq [String ]): XmlDiff = {
82- val leftText = left.child.collect({ case t : Text => t }).map(_.text.trim).mkString
83- val rightText = right.child.collect({ case t : Text => t }).map(_.text.trim).mkString
82+ def extractText (node : Node ): String = node.child.collect({ case a : Atom [_] => a }).map(_.text.trim).mkString
83+ val leftText = extractText(left)
84+ val rightText = extractText(right)
8485
8586 if (leftText != rightText) {
8687 XmlDiffers (" different text" , leftText, rightText, extendPath(path, left))
@@ -90,8 +91,8 @@ object XmlCompare {
9091 }
9192
9293 private def compareChildren (left : Node , right : Node , options : DiffOptions , path : Seq [String ]): XmlDiff = {
93- val leftChildren = left.child.filterNot(_ .isInstanceOf [Text ])
94- val rightChildren = right.child.filterNot(_ .isInstanceOf [Text ])
94+ val leftChildren = left.child.filterNot(c => c .isInstanceOf [Atom [_] ])
95+ val rightChildren = right.child.filterNot(c => c .isInstanceOf [Atom [_] ])
9596
9697 if (leftChildren.size != rightChildren.size) {
9798 XmlDiffers (" different child count" , leftChildren.size, rightChildren.size, extendPath(path, left))
0 commit comments