Advanced XPath query

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2011-01-12T21:24:27Z Indexed on 2011/01/13 3:54 UTC
Read the original article Hit count: 210

Filed under:

Hello,

I have an XML file that looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<PrivateSchool>

     <Teacher id="teacher1">
         <Name>
           teacher1Name
         </Name>
    </Teacher>

    <Teacher id="teacher2">
        <Name>
            teacher2Name
        </Name>
    </Teacher>

  <Student id="student1">
    <Name>
      student1Name
    </Name>
  </Student>

  <Student id="student2">
    <Name>
      student2Name
    </Name>
  </Student>

    <Lesson student="student1" teacher="teacher1"  />
    <Lesson student="student2" teacher="teacher2"  />
    <Lesson student="student3" teacher="teacher3"  />
    <Lesson student="student1" teacher="teacher2"  />
    <Lesson student="student3" teacher="teacher3"  />
    <Lesson student="student1" teacher="teacher1"  />
    <Lesson student="student2" teacher="teacher4"  />
    <Lesson student="student1" teacher="teacher1"  />

</PrivateSchool>

There's also a DTD associated with this XML, but I assume it's not much relevant to my question. Let's assume all needed teachers and students are well defined.

What is the XPath query that returns the teachers' NAMES, that have at least one student that took more than 10 lessons with them?

I was looking at many XPath sites/examples. Nothing seemed advanced enough for this kind of question...

Thank you

© Stack Overflow or respective owner

Related posts about xpath