0

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.

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.