Skip to main content
Selectors provide a powerful XPath-like syntax for querying nodes within a Kodexa document. Use selectors to find specific content, filter by attributes, and navigate the document structure.

Basic Selectors

Select All Nodes

Select by Node Type

Path Expressions

Absolute vs Descendant Paths

Content Filtering

Contains Function

Starts-With and Ends-With

Tag Filtering

Select Tagged Nodes

Get Tagged Node Details

Feature Filtering

Features are named values attached to a node. Filter on the presence of a feature with hasFeature(type, name), or on the value it holds with hasFeatureValue(type, name, value).
hasFeatureValue() compares against the value the feature actually stores, so it also matches a value held inside a feature’s JSON payload — a single-element list, for example.

Position Filtering

Index-Based Selection

Positional predicates are 0-based: //paragraph[0] is the first paragraph and //paragraph[1] the second. The position() and last() functions are 1-based, so //paragraph[position() <= 3] returns the first three paragraphs and //paragraph[last()] the final one. Predicates are applied in the order you write them, and both selector evaluation paths — the optimized default and the tree-walking evaluator — return the same nodes for the same expression.

Variables in Selectors

Parameterized Queries

Common Selector Patterns

Quick Reference

Real-World Examples

Working with Results

Iterating Results

Chaining Selections

Performance Tips

For large documents, optimize your selectors:
  1. Be specific with paths (//table/row/cell vs //*)
  2. Use select_first() when you only need one result
  3. Combine conditions in one selector vs multiple queries
  4. Cache selector results when iterating multiple times