XSL:使用 XPath 选择器选择元素值
我有以下 XML 方案,我想选择 Table>Row>Field with name = Amount
<?xml version="1.0" encoding="utf-8"?>
<Document>
<PermitDocument code="01312" id="1">
<Field name="DocumentType">Certificate</Field>
...
...
<Table name="Products">
<Row>
<Field name="Amount">1000</Field>
...
...
</Row>
<Row>
<Field name="Amount">3000</Field>
...
...
</Row>
</Table>
</PermitDocument>
</Document>
我有以下用于转换的代码,但没有任何反应
<xsl:for-each select="Document/PermitDocument/Table[@name='Products']/Row">
<xsl:value-of select="Field[@name='Amount']" />
...
...
</xsl:for-each>
C# 代码
XslTransform xs = new XslTransform();
try
{
xs.Load("BCIS.xsl");
}
catch (XsltException e)
{
Console.WriteLine(e.StackTrace);
Console.ReadLine();
}
xs.Transform("BCIS.xml", "BCIS.html");
我使用的语法有什么问题达到目标?
苏丹
I've the following XML scheme and I want to select the Table>Row>Field with name = Amount
<?xml version="1.0" encoding="utf-8"?>
<Document>
<PermitDocument code="01312" id="1">
<Field name="DocumentType">Certificate</Field>
...
...
<Table name="Products">
<Row>
<Field name="Amount">1000</Field>
...
...
</Row>
<Row>
<Field name="Amount">3000</Field>
...
...
</Row>
</Table>
</PermitDocument>
</Document>
I've the following code for transformation but nothing happens
<xsl:for-each select="Document/PermitDocument/Table[@name='Products']/Row">
<xsl:value-of select="Field[@name='Amount']" />
...
...
</xsl:for-each>
C# code
XslTransform xs = new XslTransform();
try
{
xs.Load("BCIS.xsl");
}
catch (XsltException e)
{
Console.WriteLine(e.StackTrace);
Console.ReadLine();
}
xs.Transform("BCIS.xml", "BCIS.html");
What is wrong with the syntax I used to achieve the goal?
Sultan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
输入:
XSLT:
输出:
Input:
XSLT:
Output: