Java - 从XML文件读取注释 [英] Java - Reading Comment from XML-File

查看:356
本文介绍了Java - 从XML文件读取注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从XML文件中提取注释。我找不到使用JDOM或其​​他方法来获取它们的方法。目前我使用Regex和FileReader,但我不觉得这是要走的路。

I have to extract comments from a XML-File. I couldn't find a way to get them using JDOM or something else. At the moment I use Regex and FileReader but I don't feel like this is the way to go.

你能用JDOM之类的东西从XML获取评论吗?文件?或者仅限于元素/节点和属性?

Can you use something like JDOM to get comments from a XML-File? Or ist it limited to Elements/Nodes and Attributes?

推荐答案

您需要实现一个词法处理程序。更多信息 - http://docs.oracle.com/javase/ tutorial / jaxp / dom / readingXML.html

You need to implement a lexical handler. More information over here - http://docs.oracle.com/javase/tutorial/jaxp/dom/readingXML.html

查看 Lexical Controls 一章。

这篇关于Java - 从XML文件读取注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆