Skip to content

Feature Request: option to ignore attributes by name (by array of string | regex) #666

@mav-rik

Description

@mav-rik

Description

Please consider adding an option to the parser/builder to exclude certain attributes by name. This could be implemented as an array of attribute names or a RegExp pattern, similar to existing include/exclude API patters for paths (e.g. typescript.json > exclude).

Use Case

We need to compare two XML documents by parsing and converting them into normalized XML outputs. Sometimes, one XML might contain extra attributes that are irrelevant for our comparison. If we exclude specific attributes during parsing, we'll easily compare the results then.

Suggested API:

const parser = new XMLParser({ ignoreAttributes: false, excludeAttributes: [ 'attr-to-skip', /^ns:/, // more patterns or attributes here... ] });

Expected Result:

The parser should ignore the specified attributes, ensuring they do not appear in the resulting XML tree.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions