Solved

Get XSL value from tags with different categories

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Input box width 6 28
Help needed with Powershell  XML to MySQL 5 47
Macro to import XML in Access 2013 2 42
write xml in vb.net 2 24
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.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
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).

825 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