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.

1
  • 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.
    – Matt R
    May 7, 2011 at 10:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.