无法从XML中选择-未在XSLT中正确声明名称空间
试图针对以下内容运行XSLT,但我认为名称空间有问题 XML示例:无法从XML中选择-未在XSLT中正确声明名称空间,xml,xslt,xml-parsing,Xml,Xslt,Xml Parsing,试图针对以下内容运行XSLT,但我认为名称空间有问题 XML示例: <rss version="2.0" xmlns="http://www.w3.org/ns/rex#" xmlns:mysmartprice="http://www.w3.org/2000/mysmartprice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <offers> <pubDate/> <t
<rss version="2.0" xmlns="http://www.w3.org/ns/rex#" xmlns:mysmartprice="http://www.w3.org/2000/mysmartprice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<offers>
<pubDate/>
<title>ShopClues Deals Feed</title>
<link>http://www.shopclues.com</link>
<description>Great Deals on branded products</description>
<language>en-gb</language>
<offer>
<mysmartprice:Product_Name>BreatheMaxTherapeuticPillow</mysmartprice:Product_Name>
<mysmartprice:Price>4999.00</mysmartprice:Price>
<mysmartprice:ourprice>4499.00</mysmartprice:ourprice>
<mysmartprice:URL>http://www.shopclues.com/breathe-max-therapeutic-pillow.html</mysmartprice:URL>
<mysmartprice:Prod_Image>http://cdn.shopclues.com/images/thumbnails/0/160/160/Breathe-Max-Therapeutic-P_1002001.000.CLM13218638854eca0acd18439.png</mysmartprice:Prod_Image>
<mysmartprice:Shipping_Price>0</mysmartprice:Shipping_Price>
<mysmartprice:Shipping_Time>5-7 working days</mysmartprice:Shipping_Time>
<mysmartprice:Availability>Out Of Stock</mysmartprice:Availability>
<mysmartprice:Brand>Calma</mysmartprice:Brand>
<mysmartprice:Category>Bed Linen </mysmartprice:Category>
<mysmartprice:SubCategory>Pillows</mysmartprice:SubCategory>
</offer>
</offers>
</rss>
XSLT:
我已经在顶部声明了名称空间,但是当我从XML中选择值时,没有得到任何结果
非常感谢您的帮助
提前感谢。offer位于名称空间中,因此您需要声明并使用它:
xmlns:rs="http://www.w3.org/ns/rex#"
<xsl:template name="itemTemplate" match="rs:offer">
顺便说一句,我认为在www.w3.org上添加自己的名称空间是不合法的http://www.w3.org/2000/mysmartprice. 您应该在自己拥有的域中使用名称空间,或者使用tempuri.net之类的名称作为域名。谢谢,这非常有效。我同意——这就是XML数据在声明名称空间的情况下提供给我们的方式。不仅不太合法,而且根本不合法。名称空间只能由其所有者定义;如果没有这一点,它们将不会提供任何防止名称冲突的保证。
xmlns:rs="http://www.w3.org/ns/rex#"
<xsl:template name="itemTemplate" match="rs:offer">