java - 有没有办法在java中使用DOM4J解析混合xml标签中的数据?

标签 java xml dom4j

假设这是 XML。

<A>

 <A1> 123 </A1>
 <A2> 234 </A2>
 asdfgh
</A>
<B>
 asdfgh
</B>

我只需要 A 和 B 的内容,不需要它们的子标签。

最佳答案

这不是有效的 xml。特别是标记 A 内的值。如果您有类似标记 A 的情况,那么您需要在 A 内再添加一个名为 的标记。如下所示。

<A>

 <A1> 123 </A1>
 <A2> 234 </A2>
 <value>asdfgh</value>
</A>
<B>
 asdfgh
</B>

关于java - 有没有办法在java中使用DOM4J解析混合xml标签中的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59029067/

相关文章:

java - JTextArea getColumns、getRows 返回 0

java - 在 Spring 中使用 @Cacheable 作为非参数方法

xml - 按特定顺序在 testng 套件中运行测试

java - dom4j XPath 不是节点类型

java - 需要使用 dom4j 处理文档的帮助

Java/Swing 离屏渲染(Cobra HTMLPanel -> BufferedImage)问题 : Component doesn't finish redrawing first

java - 错误: No resource found that matches the given name (at 'srcCompat' with value '@drawable-hdpi/ic_launcher' ) in eclispe

C# XmlSerializer : Create xmlns attribute on a nested object

deployment - 由 : org. dom4j.DocumentException 引起 : org. dom4j.DocumentFactory 无法转换为 org.dom4j.DocumentFactory

java - Android 反序列化 Arraylist 的速度问题