ltxmlts
    Preparing search index...

    Class XSequence<T>

    A LINQ-style sequence wrapper for arrays of XML objects.

    Wraps an array of XNode or XAttribute items and provides chainable query methods (ancestors, descendants, elements, etc.) that mirror the .NET LINQ to XML extension methods.

    const root = XElement.parse('<catalog><book id="1"><title>A</title></book><book id="2"><title>B</title></book></catalog>');
    const titles = xseq(root.elements("book")).elements("title").toArray().map(el => el.value);
    // ["A", "B"]

    Type Parameters

    Index

    Constructors

    Methods

    • Returns an iterator over the items in this sequence.

      Returns Iterator<T>

    • Groups adjacent items that share the same key into runs.

      Type Parameters

      • K

        The type of the grouping key.

      Parameters

      • keySelector: (item: T) => K

        A function that returns the grouping key for each item.

      Returns { items: XSequence<T>; key: K }[]

      An array of objects, each containing a key and an XSequence of adjacent items with that key.

    • Groups the items in this sequence by a key derived from each item.

      Type Parameters

      • K

        The type of the grouping key.

      Parameters

      • keySelector: (item: T) => K

        A function that returns the grouping key for each item.

      Returns Map<K, XSequence<T>>

      A map from each key to an XSequence of its matching items.

    • Removes all items in this sequence from their parents.

      Returns void

    • Materializes the sequence into a plain array.

      Returns T[]

      A new array containing all items.