Now that I have everything in the xml, while iterating through the 'container/rss/channel/item's I need to get the teamMemberIcon from the preceeding-sibling of the rss element.
The idea being that in the for-each of an <item>, you want to navigate up to the <rss> ancestor, then on-to the following <node> (sibling), then drill down into the <data> element.
xpath to access a parent's sibling node
I'm trying to show photos (that are attached to documents inside Umbraco) with posts from blogs coming from outside Umbraco.
I started with xslt created from this post: http://our.umbraco.org/wiki/how-tos/xslt-useful-tips-and-snippets/reading-rss-feeds,-aggregating-and-sorting
I then added the author's node inside the container which is giving me the following xml:
<container>
<?xml-stylesheet type="text/xsl" ....>
<rss>
<channel>
<title>My Blog</title>
<link>http://myurl.com/</link>;
<description>My Title</description>
<item>
<title>My Post Title</title>
<link>http://myurl.com/myposttitle</link>;
<pubDate>Thu, 01 Apr 2010 12:13:00 GMT</pubDate>
<description>
My Post description
</description>
</item>
</channel>
</rss>
<node id="1200" nodeName="My Name" nodeTypeAlias="teamMember">
<data alias="teamMemberIcon">/media/18301/my-photo.png</data>
</node>
</container>
Now that I have everything in the xml, while iterating through the 'container/rss/channel/item's I need to get the teamMemberIcon from the preceeding-sibling of the rss element.
What is the correct xpath to get this?
This might help you?
http://www.logiclabz.com/xml-xslt/get-previous-node-preceding-sibling-in-xslt-xpath.aspx
Hi Craig,
Try the following XPath:
The idea being that in the for-each of an <item>, you want to navigate up to the <rss> ancestor, then on-to the following <node> (sibling), then drill down into the <data> element.
Let us know how it works out.
Cheers, Lee.
Forgot to mention, there are many ways to navigate using XPath Axes, read more here:
http://www.w3schools.com/xpath/xpath_axes.asp
That worked great, Lee. Thanks! The only thing I had to change was the data predicate needed the @ symbol.
data[@alias='teamMemberIcon']
Yes, thanks Craig, well spotted. Thats what happens when you write XPath off the top of your head! ;-)
is working on a reply...