I am trying to run an XPath query using scala and it does not work. My Xml looks (simplified):
<application> <process type="output" size ="23"> <channel offset="0"/> .... <channel offset="4"/> </process> <process type="input" size ="16"> <channel offset="20"/> .... <channel offset="24"/> </process> </application>
I want to get a process with an input attribute, and for this I use this XPath request:
//process[@type='input']
This should work, I checked it with xpathtester Now my scala code looks like this:
import scala.xml._ val x = XML.loadFile("file.xml") val process = (x \\ "process[@type='input']") // will return empty NodeSeq() !!!
process ends up empty, it does not capture what I want. I worked like this:
val process = (x \\ "process" filter( _ \"@type" contains Text("input")))
which is much uglier. Any known reason why my original request should not work?
source share