1

Could someone explain to me the difference between these two expressions and give me an example where they are equal and another where they are different? Because for me they are the same

//B[position() = 1]

/descendant::B[position() = 1]
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Take

<B>
  <A>A1</A>
  <B>B1</B>
</B>

as the sample input, that way your second expression selects the first B element only while your first one selects both B elements (as it translates into /descendant-or-self::node()/B[1]).

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110