1

If I make a variable like this:

val x = <a>H<b>i</b>!</a>

how does Scala represent the text objects? If I were making the system, you'd have some List of elements that looks something like this:

L(0): TextElement = TextElement("h")
L(1): BElement    = BElement(TextElement("i"))
L(2): TextElement = TextElement("!")

But I don't see anything about text elements in any documentation (or really very much about how this works at all.)

How is it implemented in Scala?

1
  • what do you mean by "represent the text objects"? There is a scala.xml.Text class which does what I think you are asking for. Commented Mar 22, 2011 at 3:55

1 Answer 1

4

it is xml.Text :

scala> x.child.map(_.getClass).foreach(println)
class scala.xml.Text
class scala.xml.Elem
class scala.xml.Text

http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/library/scala/xml/package.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.