0

I have an XML document structured like:

<document>
  <Imposed_TimeSeries>
  ...
  </Imposed_TimeSeries>

  <Confirmed_TimeSeries>
  ...
  </Confirmed_TimeSeries>
</document>

I would like to get a NodeSeq of all TimeSeries elements with a filter like: (document \ "*_TimeSeries"). Is there any (easy) way to do this?

1 Answer 1

1

You can use

    val result: NodeSeq = (xml \ "_").filter(_.label.contains("TimeSeries"))

Look at the source of \ :

this \ "_" to get a list of all child elements (wildcard);

But you need \\ to access your different TimeSeries

println(result \\ "Confirmed_TimeSeries")
println(result \\ "Imposed_TimeSeries")
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.