How to access parent element in Scala XML -


scala.xml represents the XML with the nodes of the tree with the package labeled. But this tree is unidirectional in Scala 2.7, because it seems that there is no way to access the Elem given code Elem ? The same parent starts applying for document for example, in the XOM you have getParent and getDocument in the direction of the root of the tree Have to navigate. Can this be done with Scala XML API?

As mentioned by others, there are no original links to make them efficient irreversible structures For example:

  Scala> Val a = & lt; Parents & gt; & Lt; Children & gt; Me & lt; / Children & gt; & Lt; / Parent & gt; A: scala.xml.Elem = & lt; Parents & gt; & Lt; Children & gt; Me & lt; / Children & gt; & Lt; / Parent & gt; Scala & gt; Val b = a.child (0) b: scala.xml.Node = & lt; Children & gt; Me & lt; / Children & gt; Scala & gt; Val c = & lt; Newparent & gt; {B} & lt; / Newparent & gt; C: scala.xml.Elem = & lt; Newparent & gt; & Lt; Children & gt; Me & lt; / Children & gt; & Lt; / Newparent & gt; Scala & gt; A res0: scala.xml.Elem = & lt; Parents & gt; & Lt; Children & gt; Me & lt; / Children & gt; & Lt; / Parent & gt; Scala & gt; B Rage 1: Scala.xml.node = & lt; Children & gt; Me & lt; / Children & gt; Scala & gt; C res3: scala.xml.Elem = & lt; Newparent & gt; & Lt; Children & gt; Me & lt; / Children & gt; & Lt; / Newparent & gt;  

No data structure was copied. There is a lot of nodes pointing between both node a and a and a . If she has to talk to her parents, then you have to make a copy of it when you use it in c .

The way you want to navigate in that data structure, you are called a fully implemented XML cursor.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -