Solved

Get XSL value from tags with different categories

Posted on 2014-11-13
2
126 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

696 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