【发布时间】:2012-04-12 19:49:06
【问题描述】:
通过 API,我得到了一个 XML 文件,我试图通过 org.w3c.dom 和 XPath 对其进行解析。 XML 文件的一部分描述了 HTML 内容:
<Para>Since 2001, state and local health departments in the US have accelerated efforts to prepare for bioterrorism and other high-impact public health emergencies. These activities have been spurred by federal funding and guidance from the US Centers for Disease Control and Prevention (CDC) and the Health Resources and Services Administration (HRSA)
<CitationRef CitationID="B1">1</CitationRef>
<CitationRef CitationID="B2">2</CitationRef> . Over time, the emphasis of this guidance has expanded from bioterrorism to include "terrorism and non-terrorism events, including infectious disease, environmental and occupational related emergencies"
<CitationRef CitationID="B4">4</CitationRef> as well as pandemic influenza.
</Para>
这应该变成这样:
<p>Since 2001, state and local health departments in the US have accelerated efforts to prepare for bioterrorism and other high-impact public health emergencies. These activities have been spurred by federal funding and guidance from the US Centers for Disease Control and Prevention (CDC) and the Health Resources and Services Administration (HRSA)
<a href="link/B1">1</a>
<a href="link/B2">3</a> . Over time, the emphasis of this guidance has expanded from bioterrorism to include "terrorism and non-terrorism events, including infectious disease, environmental and occupational related emergencies"
<a href="link/B4">4</a> as well as pandemic influenza.
</p>
关于如何完成此任务的任何建议?主要问题是检索标签并替换它们,同时保持它们的位置。
【问题讨论】:
-
这听起来像是 XSLT 的完美工作,因为它是一种将 XML 输入转换为其他 XML 格式或 HTML 的语言。如果您需要有关 XSLT 代码的帮助,请将 XSLT 标记添加到您的问题中。