具有两个具有相同名称的子元素的元素的Xpath表达式。

时间:2015-05-31 14:59:06

标签: xml xpath

  

我需要弄清楚由两位教师共同教授的所有部分的xpath表达式。我知道如何让一个教练孩子得到所有部分,但是我迷失了如何让所有部分都有一个以上的教练孩子。

 <?xml version="1.0" encoding="UTF-8"?>
    <courses>
      <course number="341" credits="4.0">
        <title>Data Structures</title>
        <section number="01" delivery="Classroom">
          <enrollment>15</enrollment>
          <room>EA244</room>
          <instructor>
            <first>Nicole</first>
            <last>Anderson</last>
          </instructor>
        </section>
        <section number="02" delivery="Online">
          <enrollment>10</enrollment>
          <instructor>
            <first>Nicole</first>
            <last>Anderson</last>
          </instructor>
          <instructor>
            <first>Chi-Cheng</first>
            <last>Lin</last>
          </instructor>
        </section>
        <section number="03" delivery="Classroom">
          <enrollment>12</enrollment>
          <room>SH102</room>
          <instructor>
            <first>Mark</first>
            <last>Funk</last>
          </instructor>
        </section>
      </course>
      <course number="368" credits="4.0">
          <title>Introduction to Bioinformatics</title>
        <section number="01" delivery="Classroom">
          <enrollment>9</enrollment>
          <room>AT102</room>
          <instructor>
            <first>Chi-Cheng</first>
            <last>Lin</last>
          </instructor>
          <instructor>
            <first>Mingrui</first>
            <last>Zhang</last>
          </instructor>
        </section>
      </course>
      <course number="375" credits="4.0">
          <title>Computer Systems</title>
        <section number="01" delivery="ITV">
          <enrollment>18</enrollment>
                <room>EA244</room>
          <instructor>
            <first>Chi-Cheng</first>
            <last>Lin</last>
          </instructor>
        </section>
      </course>
      <course number="385" credits="3.0">
          <title>Applied Database Management Systems</title>
        <section number="01" delivery="Classroom">
          <enrollment>26</enrollment>
                <room>ST108</room>
          <instructor>
            <first>Nicole</first>
            <last>Anderson</last>
          </instructor>
        </section>
      </course>
      <course number="413" credits="3.0">
          <title>Advanced Networking</title>
        <section number="01" delivery="Online">
          <enrollment>10</enrollment>
          <instructor>
            <first>Chi-Cheng</first>
            <last>Lin</last>
          </instructor>
        </section>
      </course>
    </courses>

1 个答案:

答案 0 :(得分:2)

您可以使用string name = ((Windows.UI.Xaml.Controls.Canvas)sender).Name.ToString(); //section[instructor[2]]