xml - 如何跳过第一个 xml 元素组(标题行)
问题描述
下面是我下面的 XML 片段。我在第一组中收到完整的标题,我的数据从病房的第二个元素组开始。在这里我怎样才能跳过第一组?就像我需要避免第一行元素并需要从第二行元素中使用。一些身体可以发光,我如何通过 XSLT 实现这一点?
<?xml version='1.0' encoding='UTF-8'?>
<root>
<row>
<Empl-Id>Empl Id</Empl-Id>
<Company>Company</Company>
<firstname>firstname</firstname>
<lastname>lastname</lastname>
<Goal-Amount>Goal Amount</Goal-Amount>
</row>
<row>
<Empl-Id>0111</Empl-Id>
<Company>A11</Company>
<firstname>Jumn</firstname>
<lastname>Henrry</lastname>
<Goal-Amount>100</Goal-Amount>
</row>
<row>
<Empl-Id>0112</Empl-Id>
<Company>A12</Company>
<firstname>Jumn2</firstname>
<lastname>Henrry2</lastname>
<Goal-Amount>120t</Goal-Amount>
</row>
解决方案
对第一行使用空元素/root/row[1]
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/root/row[1]"/>
</xsl:stylesheet>
你的输出像:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<row>
<Empl-Id>0111</Empl-Id>
<Company>A11</Company>
<firstname>Jumn</firstname>
<lastname>Henrry</lastname>
<Goal-Amount>100</Goal-Amount>
</row>
<row>
<Empl-Id>0112</Empl-Id>
<Company>A12</Company>
<firstname>Jumn2</firstname>
<lastname>Henrry2</lastname>
<Goal-Amount>120t</Goal-Amount>
</row>
</root>
请参阅提到的链接: https ://xsltfiddle.liberty-development.net/6qVRKww
推荐阅读
- azure-api-management - 如何将 API 的少数方法打包到 APIM 中的产品中?
- javascript - 我无法预览多个上传的图像。不是重复的
- nginx - nginx conf uwsgi_pass 不考虑 DNS TTL
- apache-spark-sql - 一个流中几个不同字段的平均值
- php - CakePHP 3.7.6 LegacyPasswordHasher 不起作用
- javascript - 如何使用我的网站向所有用户(会话)广播事件?
- python - 如何在 csv 文件中保持迭代行?
- ruby-on-rails - Ruby:在 Hash 中使用 try 的两种方式
- c# - 在 C# 中使用 XSD 文件验证 xml
- python - 可以从 MyBinder Python 环境中写入和访问临时文件吗?