scala-xml icon indicating copy to clipboard operation
scala-xml copied to clipboard

NodeSeq attribute search does not work as expected

Open skalsi-atlassian opened this issue 10 years ago • 3 comments

When using the back-slash operator on a NodeSeq, the behaviour does not match how XPath works. Getting the attribute value works when there's only a single element in the node sequence:

> val x = <x><a b='1'/></x>
> x \ "a" \ "@b"
res2: scala.xml.NodeSeq = 1

but fails when there are more:

> val x = <x><a b='1'/><a b='2'/></x>
> x \ "a" \ "@b"
res3: scala.xml.NodeSeq = NodeSeq()

expected:

res3: Seq(1, 2)

skalsi-atlassian avatar Jul 20 '15 00:07 skalsi-atlassian

Copy-paste from https://issues.scala-lang.org/browse/SI-9047

skalsi-atlassian avatar Jul 20 '15 00:07 skalsi-atlassian

PR at https://github.com/scala/scala-xml/pull/43

SethTisue avatar Jul 20 '15 02:07 SethTisue

Thanks @skalsi-atlassian for reporting this. As mentioned by @SethTisue there is a PR ready to go. Also please do have a look at PR, if you can spare any amount of time.

Thanks again.

biswanaths avatar Jul 20 '15 07:07 biswanaths