XML·XML from well-formed documents to XSLT

XPath

Navigate the XML tree with paths, predicates and functions.

Beginner 13 min read Lesson 5 of 300 Challenge included
What you will be able to do
  • Use / for children and // for descendants.
  • Use @ for attributes.
  • Use predicates to filter.
  • Use text() and functions such as count().

In plain English

XPath addresses nodes with paths such as /course/lessons/lesson. Predicates filter with [@minutes > 10], and axes such as ancestor and following-sibling move through the tree. XPath 1.0 and 2.0 differ; know which your tool supports.

xpath.txtHTML
/course/lessons/lesson[@minutes > 10]
//lesson[last()]
count(//lesson)
Your turn

Select a child

Easy

Write an XPath that selects title elements under course.

HTML · starter
/course
Check your understanding before moving on.
Knowledge checkQuestion 1

What does // select?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: XSLT
Lesson 5 of 300 · 0% of course