# Set difference and intersection

These operators are new in XPath 2.0.

The expression `E1 except E2` selects all nodes that are in `E1` unless they are also in `E2`. Both expressions must return sequences of nodes. The results are returned in document order. For example, `@* except @note` returns all attributes except the `note` attribute.

The expression `E1 intersect E2` selects all nodes that are in both `E1` and `E2`. Both expressions must return sequences of nodes. The results are returned in document order. For example, `preceding::fig intersect ancestor::chapter//fig` returns all preceding `fig` elements within the current chapter.

Expand | Next