Solved

Get XSL value from tags with different categories

Posted on 2014-11-13
2
125 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

726 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