Reputation: 3665
My purpose is to get data from google place. I have the following snippet html:
<div class="rsw-pp rsw-pp-widget">
<div g:type="AverageStarRating"
g:secondaryurls="http://maps.google.com/?cid=12948004443906002997"
g:decorateusingsecondary="http://maps.google.com/?cid=12948004443906002997" g:groups="maps" g:rating_override="2.998000" class="rsw-stars">
</div>
</div>
I want to get value of g:rating_override. I tried with following xsl
<Rating>
<xsl:value-of
select="//div[@class='rsw-pp rsw-pp-widget']/div[@class='rsw-stars']/@g:rating_override" />
</Rating>
It said that 'System.Xml.Xsl.XsltException: Prefix 'g' is not defined'. Could you help me?
Upvotes: 0
Views: 571
Reputation: 138776
If you're using the Html Agility Pack embedded XSLT tools, you're facing two hard Html Agility Pack limits (at least with version 1.3.0.0):
You can overcome these limits with C# code, but not easily with pure XPATH, hence not with XSLT.
In these case, it's often easier to convert the HTML to XML using the Html Agility Pack, and then use a regular XSLT on XML with the standard .NET classes, instead of XSLT on HTML with Html Agility Pack classes.
Upvotes: 1
Reputation: 35477
You need to define the "g" namespace. Typicaly this is done on the stylesheet
element.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:g=" ... "
version="1.0">
Upvotes: 1