将普通的 Scala XML 转换为对象似乎真的很容易:
<object><field>1</field></object>
可以创建类似Object(1)
使用案例类Object( field: Int )
和 Scala 的原生 XML API 的东西。
但是如果 XML 包含名称空间和属性呢?比如一个ATOM格式?
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:service="http://activitystrea.ms/service-provider" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:gnip="http://www.gnip.com/schemas/2010">
<id>456520791711374025_380135597</id>
<published>2013-05-15T18:12:20Z</published>
<source>
<link rel="self" type="application/json" href="https://url.com/v1/tags/taghere/media/recent?client_id=xxxxxxxxxxx"/>
<updated>2013-05-15T18-12-43Z</updated>
<gnip:rule xmlns:gnip="http://www.gnip.com/schemas/2010">rulehere</gnip:rule>
</source>
<service:provider>
<name>Provider</name>
<uri>www.url.com</uri>
</service:provider>
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
<activity:object>
<activity:object-type>http://activitystrea.ms/schema/1.0/image</activity:object-type>
<gnip:statistics favoriteCount="0"/>
</activity:object>
</entry>