Solved

Get XSL value from tags with different categories

Posted on 2014-11-13
2
121 Views
Last Modified: 2014-11-13
Hi,

I have a feed with the following structure:

<feed>
  <entry>
    <tw:tags>
      <tw:tag category="category1">EntryCat1</tw:tag>
      <tw:tag category="category2">EntryCat2</tw:tag>
    </tw:tags>
  </entry>
</feed>

Open in new window


And need to get values for xsl:variable. At the moment I use the following:

<xsl:variable name="Category1" select="tw:tags/tw:tag[1]" />
<xsl:variable name="Category2" select="tw:tags/tw:tag[2]" />

Open in new window

But it is not sure that the order is always the same. I would like to implemet something like that:

<xsl:variable name="Category1" select="tw:tags/tw:tag/@category='category1'" />

Open in new window


But here I only get @Category1 = true/false. But I need @Category1 = "EntryCat1"

How should I form the select statemant to get this?

Thanks in advance
0
Comment
Question by:85521
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 40439863
Use an attribute selector:
<xsl:variable name="Category1" select="tw:tags/tw:tag[@category='category1']" />
<xsl:variable name="Category2" select="tw:tags/tw:tag[@category='category2']" />

Open in new window

More info under "Predicates" on this page: http://www.w3schools.com/xpath/xpath_syntax.asp
0
 

Author Closing Comment

by:85521
ID: 40441564
Super, thank you

I did know it is an easy answer, but as dummy I didn't find the Syntax.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML button disabled 11 36
Create XML 5 31
AWS CLI - Instances, Volumes & Tagging 2 12
Bootstrap 3 icons 3 9
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to count occurrences of each item in an array.

708 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

19 Experts available now in Live!

Get 1:1 Help Now