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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:31:49+00:00 2026-05-12T16:31:49+00:00

The scala.xml package represents XML with nodes of a labelled tree. But is this

  • 0

The scala.xml package represents XML with nodes of a labelled tree. But is this tree unidirectional in Scala 2.7, as there seems to be no way to access the Elem parent of a given Elem? The same seems to apply for parent Document. For example, in XOM you have getParent and getDocument accessors to navigate towards the root of the tree. Can this be done with Scala’s XML API?

  • 1 1 Answer
  • 1 View
  • 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-12T16:31:49+00:00Added an answer on May 12, 2026 at 4:31 pm

    As mentioned by others, there are no parent links to make them efficient immutable structures. For example:

    scala> val a = <parent><children>me</children></parent>
    a: scala.xml.Elem = <parent><children>me</children></parent>
    
    scala> val b = a.child(0)
    b: scala.xml.Node = <children>me</children>
    
    scala> val c = <newparent>{b}</newparent>
    c: scala.xml.Elem = <newparent><children>me</children></newparent>
    
    scala> a
    res0: scala.xml.Elem = <parent><children>me</children></parent>
    
    scala> b
    res1: scala.xml.Node = <children>me</children>
    
    scala> c
    res3: scala.xml.Elem = <newparent><children>me</children></newparent>
    

    No data structure was copied. The node pointed to by b is the very same node pointed to by both a and c. If it had to point to a parent, then you’d have to make a copy of it when you used it in c.

    To navigate in that data structure the way you want, you need what is called a Purely Applicative XML Cursor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two scala.xml.Elem objects (actual, expected). I am using JUnit 4, but have
I'm not familiar with the scala XML library. Is there a simple way to
I have a Scala representation of some XML (i.e. a scala.xml.Elem ), and I'd
So I have val list:List[Any]; def toElement(a:Any):scala.xml.Elem; And I want to write somthing like
I assume that there is probably no satisfactory answer to this question, but I
Consider this code: import scala.xml.{Node,HasKeyValue} def domatch(x:Node): Node = { val hasBar = new
I use scala.xml.PrettyPrinter to format my XML in Scala. The problem is with nodes
I'm trying to iterate over all the attributes in a scala.xml.Elem and get the
Given a scala.xml.Node object (with white space and elements as child nodes) what's the
I keep getting this error: [error] found : (scala.xml.NodeSeq, Int) => scala.xml.NodeSeq [error] required:

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.