Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xpath Help,....again

Status
Not open for further replies.

SgtPeppa

Programmer
Jul 7, 2003
154
DE
Given this XmlStructure:

Code:
<channel>
	<title>ChannelTitle</title>
	<link>link</link>
	<description>des</description>
	<item>
		<title>Item1Title</title>
		<link>link1</link>
		<description>des1</description>
	</item>
	<item>
		<title>Item2Title</title>
		<link>link2</link>
		<description>link3</description>
	</item>
</channel>

i want to read the node description where the title = Item1Title

Heres my try but this aint working:

//channel/item/title['Item1Title']/../description

anyone what I am doing wrong?

Thanks,

Stephan
 
Nothing wrong. Works for me. You using a default namespace? Could also try:

Code:
//channel/item[title='Item1Title']/description
 
Code:
//channel/item/title[text() = 'Item1Title']/../description

should do it


 
This worked perfect!

//channel/item[title='Item1Title']/description

Thanks a million to both of you!

Stephan
 
.. interesting Jon, I didn't know you could specify child nodes in the axis. nice one ;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top