Solved

XML/RSS - How to pass Atom link href to xsl variable

Posted on 2012-04-06
3
268 Views
Last Modified: 2012-12-09
I have an XML...

<channel>
<atom:link href="http://www.mysite.com/rss/?m=look" rel="self" type="application/rss+xml"/>
<title></title>
<link>http://www.site.com/content/</link>
<pubDate>Fri, 06 Apr 2012 19:28:44 CDT</pubDate>
<lastBuildDate>Fri, 06 Apr 2012 19:28:44 CDT</lastBuildDate>
<ttl>5</ttl> 

Open in new window


How to I pass the Atom link href (http://www.mysite.com/rss/?m=look) to the xsl variable below?

<xsl:variable name="thisurl" select="ATOM_HREF_LINK_HERE"/>

Open in new window


is that possible?
0
Comment
Question by:dimsouple
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 37819109
<xsl:variable name="thisurl" select="/channel/atom:link/@href"/>

Open in new window


make sure you bind the atom namespace to the correct namespace uri
and that you have the variable in context

there is way too little context in this question to be more detailed
It is not whole of the XML source (the atom: namespace binding is missing)
and we don't know wheiter you need a global variable, wheither there is more than one channel in your atom and hat the context of the variable is.

But in general, the above should be it
0
 

Author Comment

by:dimsouple
ID: 37838281
A siample RSS feed is @
http://www.martellyhaiti.com/rss/?m=messages

The stylesheet is @
http://www.martellyhaiti.com/rss/rss.xsl

It works fine if I set:
<xsl:variable name="thisurl" select="'http://www.martellyhaiti.com/rss?m=messages'"/>

If I change it to:
<xsl:variable name="thisurl" select="/channel/atom:link/@href"/>

Open in new window

The rss page shows a blank page. What I am doing wrong?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 37838496
as I said...
make sure you bind the atom namespace to the correct namespace uri

make this your stylesheet element and it will work

<xsl:stylesheet version="1.1" 
	xmlns:atom="http://www.w3.org/2005/Atom" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Open in new window


Note that in general it is not a good idea to use the stylesheet version 1.1
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now