1

I'm trying to iterate over all the attributes in a scala.xml.Elem and get the namespace, attribute name and value as a String. I've found it a bit hard going to be honest; is there a better way to do it than:

 elem.attributes map { md => (md.getNamespace(elem), md.key, md.value(0).text) } 

1 Answer 1

5

I don't think there is a better way to do this. If you need to extract data from MetaData objects a lot, you could write your own extractor to get nicer syntax.

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

1 Comment

Fair enough! The above is not exactly verbose, of course, but it just seemed unnecessarily painful to discover. I have hopes for anti-xml, but they don't appear to have namespace support yet.

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.