XPath wildcards and contains() function usage

I have a problem using XPath and contains function. Imagine the XML example below:

   <doc>  
     <Test>
       <Name>1 Pre Histoy</Name>
       <Type>Known</Type>
       <Data>
          <Name>Dinasor</Name>
          <Name>Fish</Name>
      </Data>
      </Test>

      <Test>
        <Name>1 Post Histoy</Name>
        <Type>Known</Type>
        <Data>
          <Name>Human</Name>
          <Name>Dog</Name>
        </Data>
     </Test>

      <Test>
        <Name>1 Post Histoy</Name>
        <Type>UNKNOWN</Type>
        <Data>
          <Name>Human</Name>
          <Name>Dog</Name>
        </Data>
     </Test>  

  </doc>

So what I want to do is returning all texts within node, with following criteria:

  1. doc//Test/Name should contain "Pre" text

  2. doc//Test/Type should be "Known"

What I need is a query like this but so far I couldn't manage it

/doc//Test[Name contains(.,'Pre') and Type='Known']/data//Name

Any help and tips will be appreciated.

11
задан BoltClock 12 April 2011 в 20:02
поделиться