Metreeca MIME
    Preparing search index...

    Type Alias XPath

    XPath: (path: string) => readonly Target[]

    XPath selector over parsed X/HTML trees.

    Selects nodes and computed values from a set of Target nodes, using XPath 1.0 expressions. The target set is fixed when the selector is created.

    Type Declaration

      • (path: string): readonly Target[]
      • Selects values.

        Each selection spans the whole target set: the expression is evaluated with each target as context node, and the results are merged into a single list. All XPath 1.0 axes, node tests, predicates, operators and core functions are supported.

        Expressions computing a string, a number or a boolean, such as count(//item), return the computed value for each target. Computed values have no tree, so selecting from them returns nothing.

        Names are matched case-sensitively, exactly as stored in the tree, and namespaces are not resolved. The same expressions therefore work on both XML and HTML trees, whose names are folded to lowercase while parsing:

        • an unprefixed name test matches unprefixed names only, so item matches <item> even under a default namespace, but not <d:item>
        • a prefixed name test matches the prefix as written, so d:b matches <d:b> whatever namespace URI d is bound to, but not the same element written with a different prefix
        • local-name() returns a name without its prefix and name() returns it in full, so <d:b> matches both local-name()='b' and name()='d:b'
        • namespace-uri() returns the prefix of a name rather than a namespace URI; the xml prefix is the exception, bound to its standard URI, so @xml:base and lang() work as specified
        • xmlns declarations are ordinary attributes, selected by attribute steps like any other

        XML declarations, document type declarations and processing instructions are not part of the tree, so processing-instruction() selects nothing. Namespace nodes are not supported either, so namespace:: selects nothing. CDATA sections are read as text nodes.

        Parameters

        • path: string

          The selection expression

        Returns readonly Target[]

        An immutable list of the values selected by path, ordered by target and, within each target, in document order, without duplicate nodes; empty if path selects no value

        SyntaxError If path is malformed