Common idiom in Java to Scala, traverse/Iterate Java list into Scala list

Posted by Berlin Brown on Stack Overflow See other posts from Stack Overflow or by Berlin Brown
Published on 2010-04-23T14:02:41Z Indexed on 2010/04/23 14:13 UTC
Read the original article Hit count: 471

Filed under:

I am processing a XML document and iterating through nodes. I want to iterate through the nodes and build a new List of some type. How would I do this with Scala:

Here is my XML traverse code:

  def findClassRef(xmlNode: Elem) = {

    xmlNode\"classDef" foreach { (entry) =>
        val name    = entry \ "@name"
        val classid = entry \ "@classId"
        println(name + "//" + classid)

Where the line of println is, I want to append elements to a list.

© Stack Overflow or respective owner

Related posts about scala

Related posts about java