How to use id operation in Node-set Function Using XPath in Xml

In this article I will explain id operation of node-set function.
  • 1866
Introduction

The Id function of node-set is used to select the elements by their unique id, and it returns the  nodes of the id that we mention in the id operation of node-set.

Syntax
 
node-set id (object)

Let us take an example

Example

code for example.xml

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

<equation>

  <xyz x="x11">

    <xyz x="x12">

      <xyz>

        <abc>abc31</abc>

        <abc>abc32</abc>

      </xyz>

    </xyz>

  </xyz>

  <xyz x="x11">

    <xyz x="x12">

      <abc>abc21</abc>

      <abc>abc22</abc>

    </xyz>

  </xyz>

  <xyz x="x11">

    <abc>abc11</abc>

    <abc>abc12</abc>

  </xyz>

  <xyz>

    <abc>abc03</abc>

    <abc>abc04</abc>

  </xyz>

</equation>

Now If I use the count function in xslt file like this,

select="id('x11')"
select="id('x12')"
select="id('x11')//abc[1]"

Output

<xyz x="x11">
<xyz x="x12">
<abc>abc31</abc>

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.