简体   繁体   English

如何在Java中导航/处理原子条目链接?

[英]How to navigate / process atom entry links in Java?

I need to parse an atom document, where entry links point to other related entries. 我需要解析一个原子文档,其中的条目链接指向其他相关条目。 For example, an entry contains information about an electric meter, and a link points to another entry which contains readings made by that meter. 例如,一个条目包含有关电表的信息,而链接指向另一个包含该电表读数的条目。 Exact structure is: 确切的结构是:

https://collaborate.nist.gov/twiki-sggrid/pub/SmartGrid/GreenButtonSDK/ESPISchemaOverview.png https://collaborate.nist.gov/twiki-sggrid/pub/SmartGrid/GreenButtonSDK/ESPISchemaOverview.png

Can anyone give me a tip/starting point? 谁能给我一个提示/起点? I know basics about XML parsing in Java but navigating between entries using links just boggles my mind. 我知道有关Java中XML解析的基础知识,但是使用链接在条目之间导航只会让我感到困惑。

Using something like ROME to parse the feed would give you the feed as a collection of Entry objects. 使用ROME之类的内容来解析提要将使您将提要作为Entry对象的集合。 Each Entry has a collection of Link s, including possible a link to itself ( rel='self' ) to assign a permalink. 每个Entry都有Link的集合,包括可能指向其自身的链接( rel='self' ),以分配一个永久链接。

Navigating between entries may well involve iterating over all the entries to find the target, or you could build your own Map . 在条目之间导航很可能涉及遍历所有条目以找到目标,或者您可以构建自己的Map This doesn't take care of the logic of making the appropriate connections due to the links but it does get you the data in terms of identifiers and links. 由于链接的缘故,这并不需要考虑进行适当连接的逻辑,但是它确实会根据标识符和链接为您获取数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM