I'm very very new to scala so bear with me if this seems basic. I have the following XML file
<xml>
<things/>
<items>
<stuff name="John"/>
<stuff name="Jacob"/>
<stuff name="George"/>
<stuff name="alice"/>
</items>
</xml>
and from this file I want to see if a specific name attribute is present in a stuff tag. (ex: see if Jacob exists or see if Lisa exists within the xml file)
So far I have the following code
import scala.xml._
val xml = XML.loadFile("sample.xml")
val stuff = (xml \\ "stuff")
//The following val contains: scala.collection.immutable.Seq[scala.xml.MetaData] = List( name="John", name="Jacob", name="George", name="alice")
val names= stuff.map(_.attributes)
Now I notice that this creates a List but when I use the contains method on the val names it gives me false even for a value like alice.
val exists= names.contains("alice")
produces this output in the REPL:
exists: Boolean = false
How would I test if a value is contained in this file?