【发布时间】:2013-05-15 20:21:28
【问题描述】:
将普通的 Scala XML 转换为对象似乎很容易:
<object><field>1</field></object> 可以使用案例类 Object( field: Int ) 和 Scala 的原生 XML API 创建类似 Object(1) 的内容。
但是如果 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>
【问题讨论】:
标签: xml scala xml-parsing xml-serialization