Skip to content

Array order guarantee #839

Description

@hartikainen-ville

Does the library guarantee that the order of elements in the result array matches their order in the original XML document?

For example, let's consider the following XML:

<Document>
    <BkToCstmrStmt>
        <Stmt>
            <Ntry>...entry 1 content...</Ntry>
            <Ntry>...entry 2 content...</Ntry>
            <Ntry>...entry 3 content...</Ntry>
            <Ntry>...entry 4 content...</Ntry>
        </Stmt>
     </BkToCstmrStmt>
</Document>

This XML is then parsed with preserveOrder: false and an isArray callback that forces Document.BkToCstmrStmt.Stmt.Ntry to always be an array.

Is the resulting Ntry element array (Ntry: [entry1, entry2, entry3, entry4]) always in document order — entry 1 first, entry 2 second, and so on? Does this also hold if other sibling elements appear between the elements? And could such an implementation detail change between versions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions