โหมด XPath

ใน 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)

ค่าพื้นฐาน (หรือเรียกว่าจุดเริ่มต้น หรือ Atomic value) ไม่มีพ่อหรือมีลูก

ตัวอย่างของค่าพื้นฐาน:

J K. Rowling
"en"

โหมด (Item)

โหมดเป็นค่าพื้นฐานหรือโหมด

ความสัมพันธ์โหมด

หลักทางพ่อ (Parent)

แต่ละ element และ attribute มีพ่อเดียวกัน

ในตัวอย่างด้านล่าง element book คือ element ที่เป็นพ่อของ element title, author, year และ price:

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

หลักทางลูก (Children)

element ของโหมดสามารถมีลูกโหมดซ้ำ หรือไม่มี หรือมีหลายโหมด

ในตัวอย่างด้านล่าง element title, author, year และ price คือ element ที่เป็นลูกของ element book:

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

หลักทางพี่น้อง (Sibling)

โหมดที่มีพ่อเดียวกัน

ในตัวอย่างด้านล่าง element title, author, year และ price คือ element ที่เดียวกัน:

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

หลักทางเดิม (Ancestor)

หลักของโหมด โหมดของโหมด และนั้นเป็นต้น

ในตัวอย่างด้านล่าง หลักของ element title คือ element book และ bookstore:

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

หลักทางลำดับ (Descendant)

หลักของโหมด โหมดของโหมด และนั้นเป็นต้น

ในตัวอย่างด้านล่าง หลักคู่หน้า bookstore คือ element ของ book, title, author, year และ price:

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