简体   繁体   English

从Java中的OPML文件提取提要列表

[英]Extract feeds list from an OPML file in java

I want to extract a list of feed information from an OPML file in java. 我想从Java中的OPML文件中提取提要信息列表。 I know I have to use some xml-parse technique, but I have no idea what to use. 我知道我必须使用一些xml-parse技术,但是我不知道该使用什么。

I am a java beginner, so could you tell me how to do it and give me an example? 我是Java初学者,所以您能告诉我该怎么做并举一个例子吗?

Thanks a lot!! 非常感谢!!

This should fairly straight forward. 这应该很简单。 You can take one of hte following two approaches. 您可以采用以下两种方法之一。

  1. Use java parsing capabilities and parse it as any XML file. 使用Java解析功能,并将其解析为任何XML文件。 Here is an example using DOM parse. 这是使用DOM解析的示例

  2. There are lot of the open source code/libraries for doing this. 有很多开放源代码/库可以做到这一点。 Here is one such example . 这是一个这样的例子 This class has a method public ArrayList<OpmlElement> readDocument(Reader reader) . 此类具有方法public ArrayList<OpmlElement> readDocument(Reader reader) You can create a Reader object from the OPML file and pass the same to this function. 您可以从OPML文件创建Reader对象,并将其传递给此函数。 Please note that this library depends on xml Pull parser libraries . 请注意,该库取决于xml Pull解析器库 So if you do not want to add another dependency use the first approach. 因此,如果您不想添加其他依赖项,请使用第一种方法。

  3. Here is another example on this forum itself. 这是该论坛本身的另一个示例

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

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