XSLT and XPath

  • Thread starter Mariusz Sieraczkiewicz
  • Start date
M

Mariusz Sieraczkiewicz

I have three variables: a, b, c.


And sample XML tree :

<parents>
<parent>
<child1>ssfd</child1>
<child2>dfoi</child2>
<child3>dijf</child3>
</parent>
............
<parent>
<child1>s34d</child1>
<child2>d44i</child2>
<child3>d342</child3>
</parent>
<parents>

how to write XPath expression that
returns the value of the child named c,
having sibling named a with value of b.
The start point is the 'parents' element.

Sample a = 'child1', b = 's34d', c='child3'

returns d342.


Regards.
 
D

Dimitre Novatchev

This is really a very simple expression.

I'd recommend getting and playing with the XPath Visualizer:

http://www.topxml/xpathvisualizer

Good books, which also cover XPath are:

1. "XSLT Programmer's Reference" by Michael Kay

2. "Beginning XSLT" by Jeni Tennison


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



Mariusz Sieraczkiewicz said:
Thx, could you suggest some reading about such complex expressions?
Use:

/parents/parent/*
[name() = $c
and
../*[name() = $a] = $b
]


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top