ブロックが繰り返される非常に大きな xml があります。最初のブロックのタグ名だけが必要です。xsl が苦手です。試してみましたが無駄でした。誰か助けてください。私のxmlは以下のとおりです。
<catalog>
<product>
<title>GATE MCQ For Electronics & Communication Engineering</title>
<originalprice>Rs 680</originalprice>
<sellingprice>Rs 680Rs 530</sellingprice>
<discount>22% Off</discount>
<payment>Cash on delivery available</payment>
<review/>
</product>
<product>
<title>Gate Guide Computer Science / Information Technology (with CD)</title>
<originalprice>Rs 695</originalprice>
<sellingprice>Rs 695Rs 480</sellingprice>
<discount>31% Off</discount>
<payment>Cash on delivery available</payment>
<review/>
</product>
製品ブロックは繰り返されますが、値は異なります。私が今使っている私のxslは、
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.java2s.com"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="//*[local-name() = 'product'][1]/*">
<xsl:value-of select="name()"/>
</xsl:template>
</xsl:stylesheet>
そして、得られる出力は、
title
originalprice
sellingprice
discount
payment
review
Gate Guide Computer Science / Information Technology (with CD)
Rs 695
Rs 695Rs 480
31% Off
Cash on delivery available
しかし、必要な出力は、
title
originalprice
sellingprice
discount
payment
review
ありがとうございました。