-
- Notifications
You must be signed in to change notification settings - Fork 339
Closed
Labels
Description
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.