tags:

views:

31

answers:

2

I have a XMLDataSource somewhat like:

<bookstore>
  <author>author1</author>
  <publication>publication1</publication>
  <book>
    <genre>Thriller</genre>
    <name>ABC</name>
  </book>
  <book>
    <genre>Romance</genre>
    <name>XYZ</name>
  </book>
  <book>
    <genre>Horror</genre>
    <name>000</name>
  </book>
</bookstore>

I am storing these in a asp:formview. I am able to store author and publication values but not sure how can I store the value of book/name based on some condition? Actually I just want to use condition that I need to store the value of "name" if "genere=Romance". something like this. I tried using XPath expression bookstore/book/genre[. ='Romance'] but not sure how to access the value of tag. Checked the following resource:

http://msdn.microsoft.com/en-us/library/ms256086.aspx

Appreciate if someone can help me.

A: 

You probably need to add /text() to get the contents of the XML tag instead of just the tag. There is a great XML cheat-sheet here that should help you.

Michael Shopsin
+2  A: 

I tried using XPath expression bookstore/book/genre[. ='Romance'] but not sure how to access the value of tag

Almost. This XPath expression:

/bookstore/book[genre='Romance']/name

String value: XYZ

Alejandro