Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7559397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:37:32+00:00 2026-05-30T12:37:32+00:00

I’m just learning scala and im trying to import an XML file to a

  • 0

I’m just learning scala and im trying to import an XML file to a Map. The XML holds definitions using <word></word> and <description></description>. When I attempt to create the map I get the error:

Value update is not member of scala.collection.immutable.Map[String, String]

Any pointers would be appreciated!

    package main
import scala.xml._

object main {

  def main(args: Array[String]): Unit = {
    val definitions = XML.load("src\\main\\Definitions.xml");
    val definitionMap = (Map[String, String]() /: (definitions \ "word")) { (map , defNode) =>
        val word = (defNode \ "word").text.toString()
        val description = (defNode \ "description").text.toString()
        map(word) = description
    }
    println(definitions.getClass())
    println("Number of elements is " + (definitions \\ "word").size)
  }

}

and the XML is formatted as such:

<?xml version="1.0"?>
<definitions>
    <entry>
        <word>Ontology</word>
        <description>A set of representational primitives with which to model a domain of knowledge or discourse.</description>
    </entry>

    <entry>
        <word>Diagnostic</word>
        <description>The process of locating problems with software, hardware, or any combination thereof in a system, or a network of systems.</description>
    </entry>
    <entry>
        <word>Malware</word>
        <description>Software that is intended to damage or disable computers and computer systems.</description>
    </entry>
    <entry>
        <word>Capacitor</word>
        <description>A device used to store an electric charge, consisting of one or more pairs of conductors separated by an insulator.</description>
    </entry>
    <entry>
        <word>Stress Test</word>
        <description>A test measuring how a system functions when subjected to controlled amounts of stress.</description>
    </entry>
    <entry>
        <word>Registry</word>
        <description>A hierarchical database that stores configuration settings and options on Microsoft Windows operating systems.</description>
    </entry>
    <entry>
        <word>Antivirus</word>
        <description>Designed to detect and remove computer viruses.</description>
    </entry>
</definitions>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:37:34+00:00Added an answer on May 30, 2026 at 12:37 pm

    You can’t change immutable data structures, that’s what compiler wants to say. Instead of updating,

    map(word) = description
    

    you should continuously add records to map.

    map + (word -> description)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have just tried to save a simple *.rtf file with some websites and
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an XML file, the creators of it stuck in a bunch social
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.