java - 获取 XML 注释值
问题描述
我有这个 XML 文件:
<!--
@author: test
@ticket: 433
-->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
我想获取@author 和@ticket 的值。我试过这个:
XMLStreamReader xr = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream("C:\\rootApplicationContext.xml"));
while (xr.hasNext()) {
if (xr.next() == XMLStreamConstants.COMMENT) {
String comment = xr.getText();
System.out.println("!!!!! comment " + comment);
} }
但我将整个评论作为一个字符串。有没有办法获取键值对?
解决方案
推荐阅读
- c# - 反接错误
- latex - \newcommand 与 Kritr 中的参数不起作用
- java - 该项目不适用于 servlet 4.0 和 jsf 2.3
- spinnaker - 使用 Spinnaker 表达式辅助函数进行身份验证
- android - Firebase .setCurrentScreen 用于基于视图的应用
- google-apps-script - Google 表格插件:创建 doGet 和 doPost 端点
- javascript - Datatables.net 选择表上的所有行,包括未显示的行
- .net-core - .net Core - 使包版本与程序集版本相同
- java - JNI - Java 应用程序的 C++ 变量值
- javascript - JS逆向工程有点值