stax-xml
stax-xml
stax-xml
Section titled “stax-xml”Classes
Section titled “Classes”StaxXmlParser
Section titled “StaxXmlParser”Defined in: StaxXmlParser.ts:113
High-performance asynchronous XML parser with circular buffer queue optimization.
This parser provides memory-efficient processing of large XML files through streaming with support for pull-based parsing, custom entity handling, and namespace processing.
OPTIMIZATION: Replaces array-based queue with circular buffer for O(1) operations. Achieved improvement: ~15% on large XML files (1GB+).
Remarks
Section titled “Remarks”The parser uses UTF-8 safe processing with Boyer-Moore-Horspool pattern search optimization and supports both single-event and batch processing modes for improved performance.
Example
Section titled “Example”Basic usage:
const xmlContent = '<root><item>Hello</item></root>';const stream = new ReadableStream({ start(controller) { controller.enqueue(new TextEncoder().encode(xmlContent)); controller.close(); }});
const parser = new StaxXmlParser(stream);for await (const event of parser) { console.log(event.type, event);}Implements
Section titled “Implements”AsyncIterator<AnyXmlEvent>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StaxXmlParser(
xmlStream,options):StaxXmlParser
Defined in: StaxXmlParser.ts:206
Creates a new StaxXmlParser instance.
Parameters
Section titled “Parameters”xmlStream
Section titled “xmlStream”ReadableStream<Uint8Array<ArrayBufferLike>>
The ReadableStream containing XML data as Uint8Array chunks
options
Section titled “options”StaxXmlParserOptions = {}
Configuration options for the parser
Returns
Section titled “Returns”Throws
Section titled “Throws”When xmlStream is not a valid ReadableStream
Example
Section titled “Example”const xmlData = '<root><item>content</item></root>';const stream = new ReadableStream({ start(controller) { controller.enqueue(new TextEncoder().encode(xmlData)); controller.close(); }});
const parser = new StaxXmlParser(stream, { autoDecodeEntities: true, maxBufferSize: 64 * 1024, initialQueueCapacity: 2048});Accessors
Section titled “Accessors”XmlEventType
Section titled “XmlEventType”Get Signature
Section titled “Get Signature”get XmlEventType():
object
Defined in: StaxXmlParser.ts:1176
Returns
Section titled “Returns”object
START_DOCUMENT
Section titled “START_DOCUMENT”
readonlySTART_DOCUMENT:"START_DOCUMENT"='START_DOCUMENT'
END_DOCUMENT
Section titled “END_DOCUMENT”
readonlyEND_DOCUMENT:"END_DOCUMENT"='END_DOCUMENT'
START_ELEMENT
Section titled “START_ELEMENT”
readonlySTART_ELEMENT:"START_ELEMENT"='START_ELEMENT'
END_ELEMENT
Section titled “END_ELEMENT”
readonlyEND_ELEMENT:"END_ELEMENT"='END_ELEMENT'
CHARACTERS
Section titled “CHARACTERS”
readonlyCHARACTERS:"CHARACTERS"='CHARACTERS'
readonlyCDATA:"CDATA"='CDATA'
readonlyERROR:"ERROR"='ERROR'
Methods
Section titled “Methods”nextBatch()
Section titled “nextBatch()”nextBatch(
size?):Promise<AnyXmlEvent[]>
Defined in: StaxXmlParser.ts:563
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Promise<AnyXmlEvent[]>
batchedIterator()
Section titled “batchedIterator()”batchedIterator(
batchSize?):AsyncGenerator<AnyXmlEvent[]>
Defined in: StaxXmlParser.ts:582
Parameters
Section titled “Parameters”batchSize?
Section titled “batchSize?”number
Returns
Section titled “Returns”AsyncGenerator<AnyXmlEvent[]>
next()
Section titled “next()”next():
Promise<IteratorResult<AnyXmlEvent,any>>
Defined in: StaxXmlParser.ts:837
Returns
Section titled “Returns”Promise<IteratorResult<AnyXmlEvent, any>>
Implementation of
Section titled “Implementation of”AsyncIterator.next
[asyncIterator]()
Section titled “[asyncIterator]()”[asyncIterator]():
AsyncIterator<AnyXmlEvent>
Defined in: StaxXmlParser.ts:856
Returns
Section titled “Returns”AsyncIterator<AnyXmlEvent>
StaxXmlParserSync
Section titled “StaxXmlParserSync”Defined in: StaxXmlParserSync.ts:50
TRUE INCREMENTAL State Machine XML Parser
Eliminates Generator overhead while maintaining StAX pull-based API Parses exactly ONE event per next() call (true incremental)
Performance: +20.67% improvement vs Generator baseline
Implements
Section titled “Implements”Iterable<AnyXmlEvent>Iterator<AnyXmlEvent>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StaxXmlParserSync(
xml,options):StaxXmlParserSync
Defined in: StaxXmlParserSync.ts:104
Parameters
Section titled “Parameters”string
options
Section titled “options”Returns
Section titled “Returns”Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<AnyXmlEvent>
Defined in: StaxXmlParserSync.ts:122
Symbol.iterator implementation - enables for…of loops Returns self to maintain single iterator state
Returns
Section titled “Returns”Iterator<AnyXmlEvent>
Implementation of
Section titled “Implementation of”Iterable.[iterator]
next()
Section titled “next()”next():
IteratorResult<AnyXmlEvent>
Defined in: StaxXmlParserSync.ts:134
Main Iterator.next() implementation - TRUE INCREMENTAL parsing
Parses exactly ONE event per call without Generator overhead Uses state machine to track parsing progress
Performance: ~10ns/event overhead (vs ~95ns for Generator)
Returns
Section titled “Returns”IteratorResult<AnyXmlEvent>
Implementation of
Section titled “Implementation of”Iterator.next
StaxXmlWriter
Section titled “StaxXmlWriter”Defined in: StaxXmlWriter.ts:131
High-performance asynchronous XML writer implementing the StAX (Streaming API for XML) pattern.
This writer provides efficient streaming XML generation using WritableStream for handling large XML documents with automatic buffering, backpressure management, and namespace support.
This is an optimized implementation with:
- Optimization 1: Regex caching for entity escaping
- Optimization 2: Attribute string batching
- Optimization 3: Early entity check before regex execution
Remarks
Section titled “Remarks”The writer supports streaming output with configurable buffering, automatic entity encoding, pretty printing with customizable indentation, and comprehensive namespace handling.
Examples
Section titled “Examples”Basic usage:
const writableStream = new WritableStream({ write(chunk) { console.log(new TextDecoder().decode(chunk)); }});
const writer = new StaxXmlWriter(writableStream);await writer.writeStartElement('root');await writer.writeElement('item', { id: '1' }, 'Hello World');await writer.writeEndElement();await writer.close();With pretty printing:
const options = { prettyPrint: true, indentString: ' ', autoEncodeEntities: true};const writer = new StaxXmlWriter(writableStream, options);Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StaxXmlWriter(
stream,options):StaxXmlWriter
Defined in: StaxXmlWriter.ts:168
Parameters
Section titled “Parameters”stream
Section titled “stream”WritableStream<Uint8Array<ArrayBufferLike>>
options
Section titled “options”StaxXmlWriterOptions = {}
Returns
Section titled “Returns”Methods
Section titled “Methods”writeStartDocument()
Section titled “writeStartDocument()”writeStartDocument(
version,encoding?):Promise<StaxXmlWriter>
Defined in: StaxXmlWriter.ts:273
Write XML declaration
Parameters
Section titled “Parameters”version
Section titled “version”string = '1.0'
encoding?
Section titled “encoding?”string
Returns
Section titled “Returns”Promise<StaxXmlWriter>
writeEndDocument()
Section titled “writeEndDocument()”writeEndDocument():
Promise<void>
Defined in: StaxXmlWriter.ts:298
End document (automatically close all elements)
Returns
Section titled “Returns”Promise<void>
writeStartElement()
Section titled “writeStartElement()”writeStartElement(
localName,options?):Promise<StaxXmlWriter>
Defined in: StaxXmlWriter.ts:319
Write start element
Parameters
Section titled “Parameters”localName
Section titled “localName”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<StaxXmlWriter>
writeEndElement()
Section titled “writeEndElement()”writeEndElement():
Promise<StaxXmlWriter>
Defined in: StaxXmlWriter.ts:402
Write end element
Returns
Section titled “Returns”Promise<StaxXmlWriter>
writeCharacters()
Section titled “writeCharacters()”writeCharacters(
text):Promise<StaxXmlWriter>
Defined in: StaxXmlWriter.ts:438
Write text
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<StaxXmlWriter>
writeCData()
Section titled “writeCData()”writeCData(
cdata):Promise<StaxXmlWriter>
Defined in: StaxXmlWriter.ts:460
Write CDATA section
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<StaxXmlWriter>
writeComment()
Section titled “writeComment()”writeComment(
comment):Promise<StaxXmlWriter>
Defined in: StaxXmlWriter.ts:480
Write comment
Parameters
Section titled “Parameters”comment
Section titled “comment”string
Returns
Section titled “Returns”Promise<StaxXmlWriter>
writeRaw()
Section titled “writeRaw()”writeRaw(
xml):Promise<StaxXmlWriter>
Defined in: StaxXmlWriter.ts:503
Write raw XML content without escaping
Parameters
Section titled “Parameters”string
Raw XML string to write
Returns
Section titled “Returns”Promise<StaxXmlWriter>
this (chainable)
flush()
Section titled “flush()”flush():
Promise<void>
Defined in: StaxXmlWriter.ts:512
Manual flush
Returns
Section titled “Returns”Promise<void>
getMetrics()
Section titled “getMetrics()”getMetrics():
object
Defined in: StaxXmlWriter.ts:519
Return metrics
Returns
Section titled “Returns”object
totalBytesWritten
Section titled “totalBytesWritten”totalBytesWritten:
number=0
flushCount
Section titled “flushCount”flushCount:
number=0
lastFlushTime
Section titled “lastFlushTime”lastFlushTime:
number=0
bufferUtilization
Section titled “bufferUtilization”bufferUtilization:
number
averageFlushSize
Section titled “averageFlushSize”averageFlushSize:
number
StaxXmlWriterSync
Section titled “StaxXmlWriterSync”Defined in: StaxXmlWriterSync.ts:44
A class for writing XML similar to StAX XMLStreamWriter. This is an optimized implementation with:
- Optimization 1: Regex caching for entity escaping
- Optimization 2: Attribute string batching
- Optimization 3: Early entity check before regex execution
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StaxXmlWriterSync(
options):StaxXmlWriterSync
Defined in: StaxXmlWriterSync.ts:70
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Methods
Section titled “Methods”writeStartDocument()
Section titled “writeStartDocument()”writeStartDocument(
version,encoding?):this
Defined in: StaxXmlWriterSync.ts:119
Writes the XML declaration (e.g., ). Should be called only once at the very beginning of the document.
Parameters
Section titled “Parameters”version
Section titled “version”string = '1.0'
XML version (default: “1.0”)
encoding?
Section titled “encoding?”string
Encoding (default: value set in constructor)
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state
writeEndDocument()
Section titled “writeEndDocument()”writeEndDocument():
void
Defined in: StaxXmlWriterSync.ts:145
Indicates the end of the document and automatically closes all open elements.
Returns
Section titled “Returns”void
Promise
getXmlString()
Section titled “getXmlString()”getXmlString():
string
Defined in: StaxXmlWriterSync.ts:162
Returns the written XML string. Should be called after writeEndDocument() to get the complete XML.
Returns
Section titled “Returns”string
The written XML string
writeStartElement()
Section titled “writeStartElement()”writeStartElement(
localName,options?):this
Defined in: StaxXmlWriterSync.ts:173
Writes a start element (e.g.,
Parameters
Section titled “Parameters”localName
Section titled “localName”string
Local name of the element
options?
Section titled “options?”Element writing options (prefix, uri, attributes, selfClosing)
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state
writeAttribute()
Section titled “writeAttribute()”writeAttribute(
localName,value,prefix?):this
Defined in: StaxXmlWriterSync.ts:265
Writes an attribute. Can only be called immediately after writeStartElement().
Parameters
Section titled “Parameters”localName
Section titled “localName”string
Local name of the attribute
string
Attribute value
prefix?
Section titled “prefix?”string
Namespace prefix of the attribute (note: this implementation does not manage namespace mapping)
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state
writeNamespace()
Section titled “writeNamespace()”writeNamespace(
prefix,uri):this
Defined in: StaxXmlWriterSync.ts:285
Writes a namespace declaration. Can only be called immediately after writeStartElement(). This implementation simply writes the string in the form xmlns:prefix=“uri” or xmlns=“uri”. Actual namespace validation/management logic is not included.
Parameters
Section titled “Parameters”prefix
Section titled “prefix”string
Namespace prefix
string
Namespace URI
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state
writeCharacters()
Section titled “writeCharacters()”writeCharacters(
text):this
Defined in: StaxXmlWriterSync.ts:309
Writes text content.
Parameters
Section titled “Parameters”string
Text to write
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state
writeCData()
Section titled “writeCData()”writeCData(
cdata):this
Defined in: StaxXmlWriterSync.ts:332
Writes a CDATA section.
Parameters
Section titled “Parameters”string
CDATA content
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state (especially when containing ’]]>’ sequence)
writeComment()
Section titled “writeComment()”writeComment(
comment):this
Defined in: StaxXmlWriterSync.ts:359
Writes a comment.
Parameters
Section titled “Parameters”comment
Section titled “comment”string
Comment content
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state (especially when containing ’—’ sequence)
writeProcessingInstruction()
Section titled “writeProcessingInstruction()”writeProcessingInstruction(
target,data?):this
Defined in: StaxXmlWriterSync.ts:382
Writes a processing instruction (Processing Instruction).
Parameters
Section titled “Parameters”target
Section titled “target”string
PI target
string
PI data (optional)
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called in incorrect state (especially when containing ’?>’ sequence)
writeRaw()
Section titled “writeRaw()”writeRaw(
xml):this
Defined in: StaxXmlWriterSync.ts:408
Writes raw XML content without escaping
Parameters
Section titled “Parameters”string
Raw XML string to write
Returns
Section titled “Returns”this
this (chainable)
writeEndElement()
Section titled “writeEndElement()”writeEndElement():
this
Defined in: StaxXmlWriterSync.ts:419
Closes the currently open element (e.g., or </prefix:element>).
Returns
Section titled “Returns”this
this (chainable)
Throws
Section titled “Throws”Error when called with no open elements
setPrettyPrint()
Section titled “setPrettyPrint()”setPrettyPrint(
enabled):this
Defined in: StaxXmlWriterSync.ts:456
Enables/disables pretty print functionality.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether to enable pretty print
Returns
Section titled “Returns”this
this (chainable)
setIndentString()
Section titled “setIndentString()”setIndentString(
indentString):this
Defined in: StaxXmlWriterSync.ts:466
Sets the indentation string.
Parameters
Section titled “Parameters”indentString
Section titled “indentString”string
String to use for indentation (e.g., ’ ’, ‘\t’, ’ ‘)
Returns
Section titled “Returns”this
this (chainable)
isPrettyPrintEnabled()
Section titled “isPrettyPrintEnabled()”isPrettyPrintEnabled():
boolean
Defined in: StaxXmlWriterSync.ts:475
Returns the current pretty print setting.
Returns
Section titled “Returns”boolean
Whether pretty print is enabled
getIndentString()
Section titled “getIndentString()”getIndentString():
string
Defined in: StaxXmlWriterSync.ts:483
Returns the current indentation string.
Returns
Section titled “Returns”string
Currently set indentation string
Interfaces
Section titled “Interfaces”StaxXmlParserOptions
Section titled “StaxXmlParserOptions”Defined in: StaxXmlParser.ts:31
Configuration options for the StaxXmlParser
Properties
Section titled “Properties”encoding?
Section titled “encoding?”
optionalencoding:string
Defined in: StaxXmlParser.ts:36
Text encoding for the input stream
Default Value
Section titled “Default Value”'utf-8'addEntities?
Section titled “addEntities?”
optionaladdEntities:object[]
Defined in: StaxXmlParser.ts:42
Additional custom entities to decode
entity
Section titled “entity”entity:
string
value:
string
Default Value
Section titled “Default Value”[]autoDecodeEntities?
Section titled “autoDecodeEntities?”
optionalautoDecodeEntities:boolean
Defined in: StaxXmlParser.ts:48
Whether to automatically decode XML entities
Default Value
Section titled “Default Value”truemaxBufferSize?
Section titled “maxBufferSize?”
optionalmaxBufferSize:number
Defined in: StaxXmlParser.ts:54
Maximum buffer size in bytes
Default Value
Section titled “Default Value”65536enableBufferCompaction?
Section titled “enableBufferCompaction?”
optionalenableBufferCompaction:boolean
Defined in: StaxXmlParser.ts:60
Whether to enable buffer compaction for memory efficiency
Default Value
Section titled “Default Value”truebatchSize?
Section titled “batchSize?”
optionalbatchSize:number
Defined in: StaxXmlParser.ts:66
Number of events to batch together
Default Value
Section titled “Default Value”1batchTimeout?
Section titled “batchTimeout?”
optionalbatchTimeout:number
Defined in: StaxXmlParser.ts:72
Timeout for batch processing in milliseconds
Default Value
Section titled “Default Value”0initialQueueCapacity?
Section titled “initialQueueCapacity?”
optionalinitialQueueCapacity:number
Defined in: StaxXmlParser.ts:78
Initial event queue capacity (circular buffer size)
Default Value
Section titled “Default Value”1024StaxXmlParserSyncOptions
Section titled “StaxXmlParserSyncOptions”Defined in: StaxXmlParserSync.ts:25
Properties
Section titled “Properties”autoDecodeEntities?
Section titled “autoDecodeEntities?”
optionalautoDecodeEntities:boolean
Defined in: StaxXmlParserSync.ts:26
addEntities?
Section titled “addEntities?”
optionaladdEntities:object[]
Defined in: StaxXmlParserSync.ts:27
entity
Section titled “entity”entity:
string
value:
string
StaxXmlWriterOptions
Section titled “StaxXmlWriterOptions”Defined in: StaxXmlWriter.ts:25
Configuration options for the StaxXmlWriter
Properties
Section titled “Properties”encoding?
Section titled “encoding?”
optionalencoding:string
Defined in: StaxXmlWriter.ts:30
Text encoding for the output stream
Default Value
Section titled “Default Value”'utf-8'prettyPrint?
Section titled “prettyPrint?”
optionalprettyPrint:boolean
Defined in: StaxXmlWriter.ts:36
Whether to format output with indentation
Default Value
Section titled “Default Value”falseindentString?
Section titled “indentString?”
optionalindentString:string
Defined in: StaxXmlWriter.ts:42
String used for indentation when prettyPrint is true
Default Value
Section titled “Default Value”' 'addEntities?
Section titled “addEntities?”
optionaladdEntities:object[]
Defined in: StaxXmlWriter.ts:48
Additional custom entities to encode
entity
Section titled “entity”entity:
string
value:
string
Default Value
Section titled “Default Value”[]autoEncodeEntities?
Section titled “autoEncodeEntities?”
optionalautoEncodeEntities:boolean
Defined in: StaxXmlWriter.ts:54
Whether to automatically encode XML entities
Default Value
Section titled “Default Value”truenamespaces?
Section titled “namespaces?”
optionalnamespaces:NamespaceDeclaration[]
Defined in: StaxXmlWriter.ts:60
Namespace declarations to include
Default Value
Section titled “Default Value”[]bufferSize?
Section titled “bufferSize?”
optionalbufferSize:number
Defined in: StaxXmlWriter.ts:66
Internal buffer size in bytes
Default Value
Section titled “Default Value”16384highWaterMark?
Section titled “highWaterMark?”
optionalhighWaterMark:number
Defined in: StaxXmlWriter.ts:72
WritableStream backpressure threshold
Default Value
Section titled “Default Value”65536flushThreshold?
Section titled “flushThreshold?”
optionalflushThreshold:number
Defined in: StaxXmlWriter.ts:78
Automatic flush threshold (percentage of bufferSize)
Default Value
Section titled “Default Value”0.8enableAutoFlush?
Section titled “enableAutoFlush?”
optionalenableAutoFlush:boolean
Defined in: StaxXmlWriter.ts:84
Whether to enable automatic flushing
Default Value
Section titled “Default Value”trueStaxXmlWriterSyncOptions
Section titled “StaxXmlWriterSyncOptions”Defined in: StaxXmlWriterSync.ts:27
Properties
Section titled “Properties”encoding?
Section titled “encoding?”
optionalencoding:string
Defined in: StaxXmlWriterSync.ts:28
prettyPrint?
Section titled “prettyPrint?”
optionalprettyPrint:boolean
Defined in: StaxXmlWriterSync.ts:29
indentString?
Section titled “indentString?”
optionalindentString:string
Defined in: StaxXmlWriterSync.ts:30
addEntities?
Section titled “addEntities?”
optionaladdEntities:object[]
Defined in: StaxXmlWriterSync.ts:31
entity
Section titled “entity”entity:
string
value:
string
autoEncodeEntities?
Section titled “autoEncodeEntities?”
optionalautoEncodeEntities:boolean
Defined in: StaxXmlWriterSync.ts:32
namespaces?
Section titled “namespaces?”
optionalnamespaces:NamespaceDeclaration[]
Defined in: StaxXmlWriterSync.ts:33
StartElementEvent
Section titled “StartElementEvent”Defined in: types.ts:66
Event fired when an XML element starts
Properties
Section titled “Properties”type:
"START_ELEMENT"
Defined in: types.ts:67
name:
string
Defined in: types.ts:68
localName?
Section titled “localName?”
optionallocalName:string
Defined in: types.ts:69
prefix?
Section titled “prefix?”
optionalprefix:string
Defined in: types.ts:70
optionaluri:string
Defined in: types.ts:71
attributes
Section titled “attributes”attributes:
Record<string,string>
Defined in: types.ts:72
attributesWithPrefix?
Section titled “attributesWithPrefix?”
optionalattributesWithPrefix:Record<string,AttributeInfo>
Defined in: types.ts:73
CharactersEvent
Section titled “CharactersEvent”Defined in: types.ts:84
Properties
Section titled “Properties”type:
"CHARACTERS"
Defined in: types.ts:85
value:
string
Defined in: types.ts:86
CdataEvent
Section titled “CdataEvent”Defined in: types.ts:89
Properties
Section titled “Properties”type:
"CDATA"
Defined in: types.ts:90
value:
string
Defined in: types.ts:91
ErrorEvent
Section titled “ErrorEvent”Defined in: types.ts:94
Properties
Section titled “Properties”type:
"ERROR"
Defined in: types.ts:95
error:
Error
Defined in: types.ts:96
XmlAttribute
Section titled “XmlAttribute”Defined in: types.ts:114
Attribute interface (for Writer)
Properties
Section titled “Properties”prefix?
Section titled “prefix?”
optionalprefix:string
Defined in: types.ts:115
localName
Section titled “localName”localName:
string
Defined in: types.ts:116
optionaluri:string
Defined in: types.ts:117
value:
string
Defined in: types.ts:118
WriteElementOptions
Section titled “WriteElementOptions”Defined in: types.ts:354
Element writing options interface (for Writer)
Properties
Section titled “Properties”prefix?
Section titled “prefix?”
optionalprefix:string
Defined in: types.ts:355
optionaluri:string
Defined in: types.ts:356
attributes?
Section titled “attributes?”
optionalattributes:Record<string,string|AttributeInfo>
Defined in: types.ts:357
selfClosing?
Section titled “selfClosing?”
optionalselfClosing:boolean
Defined in: types.ts:358
comment?
Section titled “comment?”
optionalcomment:string
Defined in: types.ts:359
Type Aliases
Section titled “Type Aliases”XmlEventType
Section titled “XmlEventType”XmlEventType = typeof
XmlEventType[keyof typeofXmlEventType]
Defined in: types.ts:6
AnyXmlEvent
Section titled “AnyXmlEvent”AnyXmlEvent =
StartDocumentEvent|EndDocumentEvent|StartElementEvent|EndElementEvent|CharactersEvent|CdataEvent|ErrorEvent
Defined in: types.ts:102
Discriminated Union type for developer use
Variables
Section titled “Variables”XmlEventType
Section titled “XmlEventType”
constXmlEventType:object
Defined in: types.ts:6
Enumeration of XML stream event types used by the StAX parser
Type Declaration
Section titled “Type Declaration”START_DOCUMENT
Section titled “START_DOCUMENT”
readonlySTART_DOCUMENT:"START_DOCUMENT"='START_DOCUMENT'
END_DOCUMENT
Section titled “END_DOCUMENT”
readonlyEND_DOCUMENT:"END_DOCUMENT"='END_DOCUMENT'
START_ELEMENT
Section titled “START_ELEMENT”
readonlySTART_ELEMENT:"START_ELEMENT"='START_ELEMENT'
END_ELEMENT
Section titled “END_ELEMENT”
readonlyEND_ELEMENT:"END_ELEMENT"='END_ELEMENT'
CHARACTERS
Section titled “CHARACTERS”
readonlyCHARACTERS:"CHARACTERS"='CHARACTERS'
readonlyCDATA:"CDATA"='CDATA'
readonlyERROR:"ERROR"='ERROR'
Functions
Section titled “Functions”isStartElement()
Section titled “isStartElement()”isStartElement(
event):event is StartElementEvent
Defined in: types.ts:297
Type guard function - Check if the event is a START_ELEMENT event
Parameters
Section titled “Parameters”XML event to check
Returns
Section titled “Returns”event is StartElementEvent
true if the event is a START_ELEMENT event, false otherwise
isEndElement()
Section titled “isEndElement()”isEndElement(
event):event is EndElementEvent
Defined in: types.ts:306
Type guard function - Check if the event is an END_ELEMENT event
Parameters
Section titled “Parameters”XML event to check
Returns
Section titled “Returns”event is EndElementEvent
true if the event is an END_ELEMENT event, false otherwise
isCharacters()
Section titled “isCharacters()”isCharacters(
event):event is CharactersEvent
Defined in: types.ts:315
Type guard function - Check if the event is a CHARACTERS event
Parameters
Section titled “Parameters”XML event to check
Returns
Section titled “Returns”event is CharactersEvent
true if the event is a CHARACTERS event, false otherwise
isCdata()
Section titled “isCdata()”isCdata(
event):event is CdataEvent
Defined in: types.ts:323
Type guard function - Check if the event is a CDATA event
Parameters
Section titled “Parameters”XML event to check
Returns
Section titled “Returns”event is CdataEvent
true if the event is a CDATA event, false otherwise
isError()
Section titled “isError()”isError(
event):event is ErrorEvent
Defined in: types.ts:331
Type guard function - Check if the event is an ERROR event
Parameters
Section titled “Parameters”XML event to check
Returns
Section titled “Returns”event is ErrorEvent
true if the event is an ERROR event, false otherwise
isStartDocument()
Section titled “isStartDocument()”isStartDocument(
event):event is StartDocumentEvent
Defined in: types.ts:339
Type guard function - Check if the event is a START_DOCUMENT event
Parameters
Section titled “Parameters”XML event to check
Returns
Section titled “Returns”event is StartDocumentEvent
true if the event is a START_DOCUMENT event, false otherwise
isEndDocument()
Section titled “isEndDocument()”isEndDocument(
event):event is EndDocumentEvent
Defined in: types.ts:347
Type guard function - Check if the event is an END_DOCUMENT event
Parameters
Section titled “Parameters”XML event to check
Returns
Section titled “Returns”event is EndDocumentEvent
true if the event is an END_DOCUMENT event, false otherwise