Scala XML: test for node existence and value

zzurrien

New Member
I am parsing a series of XML responses from a external data store. During which I must test for the existence of a child node and - if it exists - test its value. To achieve that I have the following code:\[code\]... val cond:Boolean = checkDetectionNode(row) match { case Some(nodeseq) => { val txt = nodeseq.text.toLowerCase if (txt contains "non-detect") false else true } case None => true } if (cond) val name = (row \ "CharacteristicName").text...\[/code\]checkDetectionNode is defined as such:\[code\]private def checkDetectionNode(row: scala.xml.NodeSeq) : Option[scala.xml.NodeSeq] = { if ((row \ "ResultDetectionConditionText") != null) Some[scala.xml.NodeSeq]((row \ "ResultDetectionConditionText")) else None}\[/code\]The above code results in an unspecified error of "illegal start of simple expression" on the \[code\]val name...\[/code\] line. To be honest I am not a Scala programmer or even a functional programmer (always was more partial to OO/imperative). I've only been using Scala for a few days and been basing most of what I know from Java and lambda operators. Unfortunately, I don't really have the time to sit down and really learn Scala like I wish I could. Deadlines, make fools of us all.I am hoping that someone could take a look and let me know if there is something I am doing wrong (as I am sure there is). I tried to limit the code shown to, what I hope, is relevant to the question. However, please let me know if any additional code is needed.Thanks
 
Back
Top