You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix#593: support metadata on nodes (5.x edition) (#729)
* fix#593: support line numbers
- add a new symbol, accessible via XMLParser.getStartIndexSymbol() which reflects the start index of a tag
- copy that start index in the compressed form as well
(cherry picked from commit d7601c3)
* fix#593: support line numbers
- correct .d.ts
* fix#593: support line numbers
- add a preserveStartIndex option, off by default
- use an ordinary property if Symbol is not available
- update tests and docs
* feat #593: add metadata
- add a captureMetaData which adds a metadata object
- update tests and typings
* feat #593: add metadata test
- add test for captureMetadata && isArray && stopNodes && unpairedTags && updateTag
* feat #593: update docs for metadata
- update documentation
- update fxp.d.ts for metadata
* feat #593: update .cts and .ts for metadata
- remove duplicate X2jMetadata class
- update .cts file with metadata
Copy file name to clipboardExpand all lines: docs/v4/2.XMLparseOptions.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1001,4 +1001,23 @@ const parser = new XMLParser(options);
1001
1001
constoutput=parser.parse(xmlDataStr);
1002
1002
```
1003
1003
1004
+
## captureMetadata
1005
+
1006
+
If `captureMetadata` is true, then a [Symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol) is added to nodes with metadata about that node.
1007
+
1008
+
`XMLParser.getMetaDataSymbol()` will return the symbol. Being a Symbol, this property
1009
+
will not normally appear in, for example, `Object.keys`.
1010
+
1011
+
The MetaData object is not available for nodes that resolve as strings or arrays.
constxmlData2=`<root><foo/><bar type="quux"/><bar type="bat"/><baz type="foo">FOO</baz><stop>This is a <b>stop</b> node.</stop><unpaired attr="1"></root>`;
0 commit comments