开发者

Pulling out XML attribute information in Scala

开发者 https://www.devze.com 2023-03-03 15:46 出处:网络
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 d

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) } 


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消