【发布时间】:2013-11-15 08:24:54
【问题描述】:
我需要解析被注释掉的 XML 标签
<DataType Name="SecureCode" Size="4" Type="NVARCHAR">
<!-- <Validation>
<Regex JavaPattern="^[0-9]*$" JSPattern="^[0-9]*$"/>
</Validation> -->
<UIType Size="4" UITableSize="4"/>
</DataType>
但我发现的只是setIgnoringComments(boolean)
Document doc = docBuilder.parse(new File(PathChecker.getDataTypesFile()));
docFactory.setIgnoringComments(true); // ture or false, no difference
但它似乎并没有改变任何东西。 有没有其他方法可以解析这个 cmets?我必须使用 DOM。
问候
【问题讨论】:
-
我也找到了那个帖子。它对我没有任何帮助。
-
看来 setIgnoringComments() 有 bug,已经报过,但是这些年都没有修复:issues.apache.org/jira/browse/XERCESJ-37
-
setIgnoringComments() 对我有用
标签: java xml parsing dom xml-parsing