What is XPath Nodes in XML

In this article I will explain how to select the unknown nodes in XPath.
  • 1791

Introduction

In this article I will explain how to select the unknown element in Xml.The XPath wildcards can be used to select unknown XML elements. The following are some wildcards and their description.

  • *  :  Matches any element node
  • @*   :  Matches any attribute node
  • node()  :  Matches any node of any kind

Example

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

<Employee>

  <Trainee>

    <Name>Harry</Name>

    <id>1234</id>

    <Salary>10k</Salary>

    <address street="12">Delhi</address>

  </Trainee>

  <Trainee>

    <Name>Georage</Name>

    <id>1432</id>

    <Salary>20k</Salary>

    <address street="10">Delhi</address>

  </Trainee>

</Employee>

 

The following lines listed some path expressions and the result of the expressions

  • /Employee/* : Selects all the child nodes of the Employee element.
  • //* : Selects all elements in the document.
  • //address[@*] : Selects all address elements which have any attribute.

Ask Your Question 

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

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.