【发布时间】:2014-06-20 04:04:15
【问题描述】:
我有一个用例,我想解析以下类型的 XML 文件并从中创建 HTML 报告。
<?xml version = '1.0'?>
<outer tag>
<first_tag>
<some Random xml tag>
<another tag>
</another tag>
</some Random xml tag>
</first_tag>
<first_tag>
<some Random xml tag>
<another tag>
</another tag>
</some Random xml tag>
</first_tag>
<second_tag>
<some Random xml tag>
<another tag>
</another tag>
</some Random xml tag>
</second_tag>
这个XML结构的问题是我只知道整个XML会被包裹在Outer标签中,而二级标签只能是first_tag或者second_Tag。我不知道这些二级标签中会出现什么。
我的 html 应该是这样的:
Elements inside outer_tag
First_tag children
" <some Random xml tag>
<another tag>
</another tag>
</some Random xml tag> " // XML structure itself
First_tag children :
" <some Random xml tag>
<another tag>
</another tag>
</some Random xml tag> " // XML structure itself
Second_Tag children :
" <some Random xml tag>
<another tag>
</another tag>
</some Random xml tag> " // XML structure itself
我尝试了 jaxb 和其他 XML 解析器。由于我对内部结构一无所知,我发现很难编写算法。有人可以帮我解决这个问题吗?
【问题讨论】:
标签: xml xml-parsing jaxb