• Find the first node in a XML string matching the specified path. The path is a dot separated list of tags and can include a index number to select a specific node.

    Parameters

    • xml: string

      XML string or buffer

    • path: string

      Dot separated path to the node

    Returns Node | undefined

    Node or undefined if not found

    Example

    Returns the first inner node of rootTag:

    const xml = `<rootTag> <inner /> <inner /> </rootTag>`;
    const tag = getNode(xml, 'rootTag.inner|1');