?
Solved

Get XSL value from tags with different categories

Posted on 2014-11-13
2
Medium Priority
?
129 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 2000 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

Industry Leaders: 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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

771 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