XPath node

في XPath،هناك سبعة أنواع من العقد: العناصر،الصفات،النص،النطاق،التعليمات،التعليقات والعقد الجذر (أو ما يُسمى بالعقد الجذري).

مصطلحات XPath

العقد (Node)

في XPath،هناك سبعة أنواع من العقد: العناصر،الصفات،النص،النطاق،التعليمات،التعليقات والوثيقة (العقد الجذر). الوثيقة XML يتم التعامل معها كشجرة العقد. جذع الشجرة يُسمى العقد الجذر أو العقد الجذري.

انظر إلى هذا الوثيقة XML التالية:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book>
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author> 
  <year>2005</year>
  <price>29.99</price>
</book>
</bookstore>

مثال على العقد في الوثيقة XML أعلاه:

<bookstore> (العقد الخاص بالوثيقة)
<author>J K. Rowling</author> (العقد الخاص بالعناصر)
lang="en" (العقد الخاص بالصفات) 

العناصر الأساسية (أو ما يُسمى بالقيم الذرية،Atomic value)

العناصر الأساسية هي العقد التي ليس لديها آباء أو أبناء.

مثالللعناصر الأساسية:

J K. Rowling
"en"

Item

Items are basic values or nodes.

Node relationships

Parent

Each element and attribute has a parent.

In the following example, the book element is the parent of the title, author, year, and price elements:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

Child

Element nodes can have zero, one, or more children.

In the following example, the title, author, year, and price elements are children of the book element:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

Sibling

Nodes with the same parent

In the following example, the title, author, year, and price elements are peers:

<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>

Ancestor

A node's parent, parent's parent, and so on.

In the following example, the ancestors of the title element are the book element and the bookstore element:

<bookstore>
<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>
</bookstore>

Descendant

A node's child, child's child, and so on.

In the following example, the descendants of bookstore are book, title, author, year, and price elements:

<bookstore>
<book>
  <title>Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>
</bookstore>