Expand description
XML Reader API (§30, §85 Phase 7).
Cursor-based streaming reader with node type, depth, attribute traversal, namespace lookup, value retrieval, validation integration.
Implements the xmlTextReader API from libxml2, which provides a
cursor-based streaming interface for reading XML documents. The reader
parses the entire document into a tree on the first Read() call, then
walks the tree in document order (depth-first traversal) generating
node events for elements, text, comments, PIs, etc.
§UPSTREAM-PARITY
The reader API is defined in libxml/xmlreader.h and libxml/xmlreader.c.
Key differences from upstream:
- The reader parses the full document on first Read rather than using a true streaming/event-driven parser. This simplifies the implementation while preserving the observable API surface.
- Pattern-based reader operations (xmlTextReaderPreservePattern, etc.) are not yet implemented.
Structs§
- XmlText
Reader - XmlText
Reader Locator - Opaque locator passed to the reader error handler (upstream
xmlTextReaderLocator).
Enums§
- Read
State - Reader read state (xmlTextReaderReadState enum).
- Reader
Node Type - Reader node types (xmlReaderTypes enum).
Constants§
- XML_
PARSER_ SEVERITY_ ERROR - XML_
PARSER_ SEVERITY_ VALIDITY_ ERROR - XML_
PARSER_ SEVERITY_ VALIDITY_ WARNING - Error severity (upstream
xmlParserSeverities, reader.h). - XML_
PARSER_ SEVERITY_ WARNING
Functions§
- xmlFree
Text ⚠Reader - Free a text reader.
- xmlNew
Text ⚠Reader - Create a new text reader from an input buffer.
- xmlNew
Text ⚠Reader Filename xmlTextReaderPtr xmlNewTextReaderFilename(const char *URI)— upstream xmlreader.c: creates a reader over the file, no encoding/options (R-000176: the candidate previously exported a 3-argument extension).- xmlReader
ForDoc ⚠ xmlTextReaderPtr xmlReaderForDoc(const xmlChar *cur, const char *URL, const char *encoding, int options)— reader over an in-memory XML string.- xmlReader
ForFd ⚠ - Create a text reader from a file descriptor.
- xmlReader
ForFile ⚠ - Create a text reader for a file.
- xmlReader
ForIO ⚠ - Create a text reader from I/O callbacks.
- xmlReader
ForMemory ⚠ - Create a text reader from memory.
- xmlReader
NewDoc ⚠ int xmlReaderNewDoc(xmlTextReaderPtr reader, const xmlChar *cur, const char *URL, const char *encoding, int options).- xmlReader
NewFd ⚠ int xmlReaderNewFd(xmlTextReaderPtr reader, int fd, const char *URL, const char *encoding, int options).- xmlReader
NewFile ⚠ int xmlReaderNewFile(xmlTextReaderPtr reader, const char *filename, const char *encoding, int options).- xmlReader
NewIO ⚠ int xmlReaderNewIO(xmlTextReaderPtr reader, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options).- xmlReader
NewMemory ⚠ int xmlReaderNewMemory(xmlTextReaderPtr reader, const char *buffer, int size, const char *URL, const char *encoding, int options).- xmlReader
NewWalker ⚠ int xmlReaderNewWalker(xmlTextReaderPtr reader, xmlDocPtr doc).- xmlReader
Walker ⚠ xmlTextReaderPtr xmlReaderWalker(xmlDocPtr doc)— reader walking an existing document tree.- xmlText
Reader ⚠Attribute Count - Get the attribute count of the current element.
- xmlText
Reader ⚠Base Uri - Get the base URI of the current node.
- xmlText
Reader ⚠Byte Consumed long xmlTextReaderByteConsumed(xmlTextReaderPtr reader).- xmlText
Reader ⚠Close - Close the reader, releasing the document and parser state.
- xmlText
Reader ⚠Const Base Uri const xmlChar *xmlTextReaderConstBaseUri(xmlTextReaderPtr reader)— the base URI, valid until the reader is freed (no copy).- xmlText
Reader ⚠Const Encoding const xmlChar *xmlTextReaderConstEncoding(xmlTextReaderPtr reader).- xmlText
Reader ⚠Const Local Name const xmlChar *xmlTextReaderConstLocalName(xmlTextReaderPtr reader).- xmlText
Reader ⚠Const Name - Get a constant pointer to the name (no copy).
- xmlText
Reader ⚠Const Namespace Uri const xmlChar *xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader).- xmlText
Reader ⚠Const Prefix const xmlChar *xmlTextReaderConstPrefix(xmlTextReaderPtr reader).- xmlText
Reader ⚠Const String const xmlChar *xmlTextReaderConstString(xmlTextReaderPtr reader, const xmlChar *str)— the reader’s dictionary-internalized copy ofstr; the candidate returnsstrunchanged (dictionary interning is an internal detail).- xmlText
Reader ⚠Const Value - Get a constant pointer to the value (no copy).
- xmlText
Reader ⚠Const XmlLang const xmlChar *xmlTextReaderConstXmlLang(xmlTextReaderPtr reader).- xmlText
Reader ⚠Const XmlVersion const xmlChar *xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader).- xmlText
Reader ⚠Current Doc - Get the current document from the reader.
- xmlText
Reader ⚠Current Node - Return the current node of the reader.
- xmlText
Reader ⚠Depth - Get the depth of the current node.
- xmlText
Reader ⚠Expand - Expand entity references at the current position.
- xmlText
Reader ⚠GetAttribute - Get an attribute value by name.
- xmlText
Reader ⚠GetAttribute No - Get an attribute value by index.
- xmlText
Reader ⚠GetAttribute Ns - Get an attribute value by local name and namespace URI.
- xmlText
Reader ⚠GetError Handler void xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, xmlTextReaderErrorFunc *f, void **arg).- xmlText
Reader ⚠GetLast Error const xmlError *xmlTextReaderGetLastError(xmlTextReaderPtr reader)— pointer to the reader’s embedded_xmlError(upstream returns&reader->ctxt->lastError, which is always present while the reader exists; valid until the next error is collected).- xmlText
Reader ⚠GetParser Column Number - Return the parser column number of the current node.
- xmlText
Reader ⚠GetParser Line Number - Return the parser line number of the current node.
- xmlText
Reader ⚠GetParser Prop - Get a parser property.
- xmlText
Reader ⚠GetRemainder xmlParserInputBufferPtr xmlTextReaderGetRemainder(xmlTextReaderPtr reader).- xmlText
Reader ⚠HasAttributes - Check if the current node has attributes.
- xmlText
Reader ⚠HasValue - Check if the current node has a value.
- xmlText
Reader ⚠IsDefault int xmlTextReaderIsDefault(xmlTextReaderPtr reader)— whether the current attribute came from the DTD default. The candidate returns 0 for a valid reader (DTD default attribute expansion is not annotated; documented divergence), -1 for a NULL reader (upstream contract).- xmlText
Reader ⚠IsEmpty Element - Check if the current element is an empty element (no children).
- xmlText
Reader ⚠IsNamespace Decl int xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader)— whether the current attribute position is a namespace declaration.- xmlText
Reader ⚠IsValid - Return the validation status of the reader.
- xmlText
Reader ⚠Local Name - Get the local name of the current node.
- xmlText
Reader ⚠Locator BaseURI xmlChar *xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator).- xmlText
Reader ⚠Locator Line Number int xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator).- xmlText
Reader ⚠Lookup Namespace - Look up a namespace by prefix.
- xmlText
Reader ⚠Move ToAttribute - Move to an attribute by name.
- xmlText
Reader ⚠Move ToAttribute No - Move to an attribute by index.
- xmlText
Reader ⚠Move ToAttribute Ns int xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, const xmlChar *localName, const xmlChar *namespaceURI).- xmlText
Reader ⚠Move ToElement - Move the reader back to the parent element (from an attribute).
- xmlText
Reader ⚠Move ToFirst Attribute - Move to the first attribute of the current element.
- xmlText
Reader ⚠Move ToNext Attribute - Move to the next attribute.
- xmlText
Reader ⚠Name - Get the name of the current node.
- xmlText
Reader ⚠Namespace Uri - Get the namespace URI of the current node.
- xmlText
Reader ⚠Next - Skip to the next sibling of the current node.
- xmlText
Reader ⚠Next Sibling - Skip to the next sibling (same as xmlTextReaderNext).
- xmlText
Reader ⚠Node Type - Get the node type of the current node.
- xmlText
Reader ⚠Normalization - Return the normalization status of the reader.
- xmlText
Reader ⚠Prefix - Get the prefix of the current node.
- xmlText
Reader ⚠Preserve xmlNodePtr xmlTextReaderPreserve(xmlTextReaderPtr reader)— the current node (the candidate’s reader owns the whole tree, so no separate preservation step is needed).- xmlText
Reader ⚠Preserve Pattern int xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern, const xmlChar **namespaces).- xmlText
Reader ⚠Prev - Skip to the previous sibling of the current node.
- xmlText
Reader ⚠Quote Char int xmlTextReaderQuoteChar(xmlTextReaderPtr reader).- xmlText
Reader ⚠Read - Advance the reader to the next node in document order.
- xmlText
Reader ⚠Read Attribute Value - Read the value of an attribute as a text node (attribute-value mode).
- xmlText
Reader ⚠Read Inner Xml - Read the inner XML of the current node as a string.
- xmlText
Reader ⚠Read Outer Xml - Read the outer XML of the current node as a string.
- xmlText
Reader ⚠Read State - Get the read state.
- xmlText
Reader ⚠Read String - Read the content of the current node as a string.
- xmlText
Reader ⚠RelaxNG SetSchema int xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema).- xmlText
Reader ⚠RelaxNG Validate int xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng).- xmlText
Reader ⚠RelaxNG Validate Ctxt int xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader, xmlRelaxNGValidCtxtPtr ctxt, int options).- xmlText
Reader ⚠Schema Validate int xmlTextReaderSchemaValidate(xmlTextReaderPtr reader, const char *xsd)— parsexsdand validate the reader’s document.- xmlText
Reader ⚠Schema Validate Ctxt int xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader, xmlSchemaValidCtxtPtr ctxt, int options).- xmlText
Reader ⚠SetError Handler int xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, xmlTextReaderErrorFunc f, void *arg).- xmlText
Reader ⚠SetMax Amplification void xmlTextReaderSetMaxAmplification(xmlTextReaderPtr reader, unsigned maxAmpl).- xmlText
Reader ⚠SetParser Prop - Set a parser property.
- xmlText
Reader ⚠SetResource Loader void xmlTextReaderSetResourceLoader(xmlTextReaderPtr reader, xmlResourceLoader loader, void *data)— install a custom resource loader; stored on the reader and forwarded to its parser context (upstream xmlreader.c).- xmlText
Reader ⚠SetSchema int xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema).- xmlText
Reader ⚠SetStructured Error Handler void xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, xmlStructuredErrorFunc f, void *arg).- xmlText
Reader ⚠Setup - Setup/reinitialize a reader with new input.
- xmlText
Reader ⚠Standalone - Return the standalone flag of the document being read.
- xmlText
Reader ⚠Value - Get the value of the current node.
- xmlText
Reader ⚠XmlLang - Return the xml:lang of the current node.
Type Aliases§
- xmlText
Reader Error Func - Reader error callback (upstream
xmlTextReaderErrorFunc).