UNPKG

partial-xml-stream-parser

Version:

A lenient XML stream parser for Node.js and browsers that can handle incomplete or malformed XML data, with depth control, CDATA support for XML serialization and round-trip parsing, wildcard pattern support for stopNodes, and CDATA handling within stopNo

14 lines (12 loc) 812 B
import { ParserOptions } from "./types" // Default options relevant to the lenient streaming parser export const DEFAULT_STREAM_OPTIONS: Required<ParserOptions> = { textNodeName: "#text", // Key for text content when a tag has other children or for consistency attributeNamePrefix: "@", // Prefix for attribute names in the parsed object stopNodes: [], // Array of tag names that should not have their children parsed maxDepth: null, // Maximum nesting depth; tags beyond this depth are treated like stopNodes alwaysCreateTextNode: true, // If true, text content is always in a #text node. Changed default for performance. parsePrimitives: false, // If true, attempts to parse numbers and booleans allowedRootNodes: null, // Allowed root nodes ignoreWhitespace: false, // Whether to ignore whitespace }