Xml 在浏览器上显示选定的标记

Xml 在浏览器上显示选定的标记,xml,xslt,Xml,Xslt,我有以下包含html标记的xml文件,如图所示: <?xml version="1.0" encoding="UTF-8"?> <!-- New XML document created with EditiX XML Editor (http://www.editix.com) at Tue Mar 18 22:41:05 IST 2014 --> <html> <head> <title> title1 </title&g

我有以下包含html标记的xml文件,如图所示:

<?xml version="1.0" encoding="UTF-8"?>

<!-- New XML document created with EditiX XML Editor (http://www.editix.com) at Tue Mar 18 22:41:05 IST 2014 
-->
<html>
<head>
<title>
title1
</title>
</head>

<body>
<fragment id="heading1">
<h1>
Heading 1
</h1>
</fragment>
<fragment id="heading2">
<h2>
Heading 2
</h2>
</fragment>
<fragment id="paragraph1">
<p>
Paragraph 1
</p>
</fragment>
</body>                  
</html>

标题1
标题1
标题2

第1款


另外,将xml数据放到浏览器上的一种方法是使用xsl。但是有没有一种方法可以使用xsl只将选定的片段标记放到浏览器窗口上?或者,我是否必须创建另一个仅包含所需标记的xml并将其显示在浏览器上。

您的示例在我看来(几乎)像HTML,因此您的第一个选择就是简单地使用CSS对其进行样式设置,并为您不想显示的元素定义
display:none
。当然,如果需要,您也可以使用XSLT转换示例,删除不希望显示的元素。您可以在xsl文件中使用XPATH选择要显示的片段标记。e、 g.,
谢谢您的建议。:)出于我的目的,我会将所有需要的标记写入不同的文件,并使用xsl显示它们。