0
回聲XML DATAS我需要使用XSLT做這樣的事情:XSLT:如何分析和處理條件
foreach(product as product{
if(itemType == "processor" && price < 100$) echo processor["brand"]
if(itemType == "laptop" && color=="black") echo laptop["price"]
)
我由於2-幾天再試使用XSLT <xsl:for-each>
發言,並<xsl:if>
語句,但我肯定不知道 即使在看過一些網絡教程後,如何正確使用它。任何人都可以幫助我嗎?
<myShop>
<product itemType="processor">
<brand>Intel</brand>
<price secondHand="false">230$</price>
<nbCore>4</nbCore>
</product>
<product itemType="processor">
<brand>Amd</brand>
<price secondHand="true">90$</price>
<nbCore>2</nbCore>
</product>
<product itemType="laptop">
<brand>Dell</brand>
<price secondHand="false">600$</price>
<color>black</color>
</product>
<product itemType="laptop">
<brand>Apple</brand>
<price secondHand="true">900$</price>
<color>silver</color>
</product>
</myShop>
編輯: 請看看這個XML代碼
<agency>
<product productType="appartement">
<price transactionType="rent">1000€</prix>
<location>Paris</location>
<surface>80m²</surface>
<bedroom>1</bedroom>
<bathoom>2</bathoom>
<heating heatingType="gaz">yes</heating>
</product>
</product>
<product productType="house">
<price productType="sell">280000€</prix>
<location>London</location>
<surface>190m²</surface>
<bedroom>3</bedroom>
<bathoom>2</bathoom>
<heating heatingType="electric">yes</heating>
</product>
</agency>
,這裏是我的XSLT樣式表
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<title>agence.xsl</title>
</head>
<body>
//help me echo house having price > 200000 and price < 300000 and having bedroom >= 3 order by location, surface desc
</body>
</html>
</xsl:template>
</xsl:stylesheet>
你能幫我有價格> 200000價格< 300000回聲房子並有臥室> = 3按地點排序,
謝謝。最後你的答案幫了我很多。 – zm455