MCPcopy Create free account
hub / github.com/NaturalIntelligence/fast-xml-parser / parseSpans

Function parseSpans

spec/endIndex_spec.js:22–26  ·  view source on GitHub ↗

Parse xml with metadata capture on and return a Map of rawTagName -> raw text span.

(xml)

Source from the content-addressed store, hash-verified

20
21/** Parse xml with metadata capture on and return a Map of rawTagName -> raw text span. */
22function parseSpans(xml) {
23 const parser = new XMLParser({ preserveOrder: true, ignoreAttributes: false, captureMetaData: true });
24 const result = parser.parse(xml);
25 return new Map(collectMeta(result).map(([tag, m]) => [tag, xml.slice(m.startIndex, m.endIndex)]));
26}
27
28describe("XMLParser captureMetaData endIndex", function () {
29 it("does not add metadata (start or end) when captureMetaData is off", function () {

Callers 1

endIndex_spec.jsFile · 0.85

Calls 2

parseMethod · 0.95
collectMetaFunction · 0.85

Tested by

no test coverage detected