Mazinger
Mazinger

Reputation: 653

Accessing especific XML element from XSL

Hello everyboby and thanks in advance,

I have this data in an XML file...

<equipos>
<equipo>
    <partidos resultado="ganados">3</partidos>
    <partidos resultado="perdidos">5</partidos>
    <partidos resultado="empatados">2</partidos>
    <partidos pepe="ganados">3</partidos>
    <partidos pepe="perdidos">5</partidos>
    <partidos pepe="empatados">2</partidos>
  </equipo>

<equipo>
    ...
</equipo>

<equipo>
    ...
</equipo>

<equipo>
    ...
</equipo>
</equipos>

First of all, is this structure correct? Is so, how can I access from XSL to the value "5" of the specific element

<"partidos pepe="perdidos">5

Thanks everybody!

Upvotes: 0

Views: 31

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116993

First of all, is this structure correct?

Not sure what you mean by "correct". The input is a well-formed XML document. I don't think we can say anything else without knowing what's the purpose here.

how can I access from XSL to the value "5" of the specific element <"partidos pepe="perdidos">

It depends on your current context. In the absence of that, the absolute path to that element would be:

<xsl:value-of select="/equipos/equipo/partidos[@pepe='perdidos']"/>

This assumes the other equipo elements do not have a similar partidos child.

Upvotes: 1

Related Questions