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 8326231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:41:57+00:00 2026-06-09T00:41:57+00:00

I got a problem which seems to be fairly common but i really don’t

  • 0

I got a problem which seems to be fairly common but i really don’t find a working approach to solve it.
i have a large xml document and will parse it. the document structure is as follows:

<response>
<result>
    <doc>
        <float name="xxx">0.0</float>
        <int name="yyy">123</int>
        <str name="zzz">hello</str>
        <str name="xyz">world</str>
    </doc>
</result></response>

and i would like to parse this information into a hash map like “Map[String, Int](yyy, 123)”(One Map fo revery Datatype).

All the examples that i found until now are explaining how i can get a result like “zzzhelloxyzworld” if i look for the “str” tag or how i can find out the “name” attribute inside an “str” tag but i know the name attribute and would like to have the information in the “str” tag.

(xmldoc \\ "str").map(n => (n \ "@name").text)

for example gives me a map of all the attribute values. but i don’t know a way to get to the data.

i hope someone can help me out here because it seems to me as such a common task and i don’t know why i couldn’t find any solution to this.

  • 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-06-09T00:41:58+00:00Added an answer on June 9, 2026 at 12:41 am
    (xmldoc \\ "str").map(n => (n \ "@name").text -> n.text).toMap
    

    gives

    scala.collection.immutable.Map[String,String] = Map(zzz -> hello, xyz -> world)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem which seems simple at first, but really isn't. I'm storing
I've got a problem which is probably very easy to solve but I can't
I have a spurious problem which seems to indicate the index value got from
I've got a problem which seems to be a real nut. I am using
Got a problem which to me make no sense. So here goes: I have
Hello stackoverflow people! I've got a problem which I haven't been able to solve
I have got a problem with calling a global function, which takes a pointer
I've got a unit test I'm writing which seems to have some kind of
Got a problem that seems to be fairly endemic with IE8 (searching on Google)
I've got another problem (which might not be an issue in terms of coding

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.