Microsoft Certified Partner Soul Solutions
Nov 24

Written by: Soul Solutions
Friday, 24 November 2006

BronwenWeeGo.jpgToday i had to filter an xml document based on the start value of an attribute and it took me ages to work it out as before i'd always done exact matches.  Plus couldn't find any egs where they used anything bar =.  So if i have a xml schema like


<books>
	<book name="Bronwens adventure"></book>
	<book name="Bronwen vacations"></book>
</books>

and i have a XMLDocument with this in it.  If i want to find all the book's whose name starts with "Bronwen" I can do a xpath query as follows:


doc.SelectNodes("//book[starts-with(@name,'Bronwen');

Tags:

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel