libxml2
Loading...
Searching...
No Matches
parser.h File Reference

Validating XML 1.0 parser. More...

Data Structures

struct  _xmlParserInput
 Parser input. More...
struct  _xmlParserCtxt
 Parser context. More...
struct  _xmlSAXLocator
 A SAX Locator. More...
struct  _xmlSAXHandler
 Callbacks for SAX parser. More...
struct  _xmlSAXHandlerV1
 SAX handler, version 1. More...

Macros

#define XML_DEFAULT_VERSION   "1.0"
 The default version of XML used: 1.0.
#define XML_SAX2_MAGIC   0xDEEDBEAF
 Special constant required for SAX2 handlers.
#define xmlDoValidityCheckingDefaultValue    (*__xmlDoValidityCheckingDefaultValue())
 Thread-local setting to enable validation.
#define xmlGetWarningsDefaultValue    (*__xmlGetWarningsDefaultValue())
 Thread-local setting to disable warnings.
#define xmlKeepBlanksDefaultValue   (*__xmlKeepBlanksDefaultValue())
 Thread-local setting to ignore some whitespace.
#define xmlLineNumbersDefaultValue    (*__xmlLineNumbersDefaultValue())
 Thread-local setting to store line numbers.
#define xmlLoadExtDtdDefaultValue   (*__xmlLoadExtDtdDefaultValue())
 Thread-local setting to enable loading of external DTDs.
#define xmlPedanticParserDefaultValue    (*__xmlPedanticParserDefaultValue())
 Thread-local setting to enable pedantic warnings.
#define xmlSubstituteEntitiesDefaultValue    (*__xmlSubstituteEntitiesDefaultValue())
 Thread-local setting to enable entity substitution.
#define xmlIndentTreeOutput   (*__xmlIndentTreeOutput())
 Thread-local setting to disable indenting when formatting output.
#define xmlTreeIndentString   (*__xmlTreeIndentString())
 Thread-local setting to change the indent string.
#define xmlSaveNoEmptyTags   (*__xmlSaveNoEmptyTags())
 Thread-local setting to disable empty tags when serializing.

Typedefs

typedef xmlParserErrors(* xmlResourceLoader) (void *ctxt, const char *url, const char *publicId, xmlResourceType type, xmlParserInputFlags flags, xmlParserInput **out)
 Callback for custom resource loaders.
typedef xmlParserInput *(* resolveEntitySAXFunc) (void *ctx, const xmlChar *publicId, const xmlChar *systemId)
 SAX callback to resolve external entities.
typedef void(* internalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 SAX callback for the internal subset.
typedef void(* externalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 SAX callback for the external subset.
typedef xmlEntity *(* getEntitySAXFunc) (void *ctx, const xmlChar *name)
 SAX callback to look up a general entity by name.
typedef xmlEntity *(* getParameterEntitySAXFunc) (void *ctx, const xmlChar *name)
 SAX callback to look up a parameter entity by name.
typedef void(* entityDeclSAXFunc) (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
 SAX callback for entity declarations.
typedef void(* notationDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 SAX callback for notation declarations.
typedef void(* attributeDeclSAXFunc) (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumeration *tree)
 SAX callback for attribute declarations.
typedef void(* elementDeclSAXFunc) (void *ctx, const xmlChar *name, int type, xmlElementContent *content)
 SAX callback for element declarations.
typedef void(* unparsedEntityDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)
 SAX callback for unparsed entity declarations.
typedef void(* setDocumentLocatorSAXFunc) (void *ctx, xmlSAXLocator *loc)
 This callback receives the "document locator" at startup, which is always the global xmlDefaultSAXLocator.
typedef void(* startDocumentSAXFunc) (void *ctx)
 SAX callback for start of document.
typedef void(* endDocumentSAXFunc) (void *ctx)
 SAX callback for end of document.
typedef void(* startElementSAXFunc) (void *ctx, const xmlChar *name, const xmlChar **atts)
 SAX callback for start tags.
typedef void(* endElementSAXFunc) (void *ctx, const xmlChar *name)
 SAX callback for end tags.
typedef void(* attributeSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *value)
 Callback for attributes.
typedef void(* referenceSAXFunc) (void *ctx, const xmlChar *name)
 SAX callback for entity references.
typedef void(* charactersSAXFunc) (void *ctx, const xmlChar *ch, int len)
 SAX callback for character data.
typedef void(* ignorableWhitespaceSAXFunc) (void *ctx, const xmlChar *ch, int len)
 SAX callback for "ignorable" whitespace.
typedef void(* processingInstructionSAXFunc) (void *ctx, const xmlChar *target, const xmlChar *data)
 SAX callback for processing instructions.
typedef void(* commentSAXFunc) (void *ctx, const xmlChar *value)
 SAX callback for comments.
typedef void(* cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len)
 SAX callback for CDATA sections.
typedef void(* warningSAXFunc) (void *ctx, const char *msg,...)
 SAX callback for warning messages.
typedef void(* errorSAXFunc) (void *ctx, const char *msg,...)
 SAX callback for error messages.
typedef void(* fatalErrorSAXFunc) (void *ctx, const char *msg,...)
 SAX callback for fatal error messages.
typedef int(* isStandaloneSAXFunc) (void *ctx)
 SAX callback to get standalone status.
typedef int(* hasInternalSubsetSAXFunc) (void *ctx)
 SAX callback to get internal subset status.
typedef int(* hasExternalSubsetSAXFunc) (void *ctx)
 SAX callback to get external subset status.
typedef void(* startElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)
 SAX2 callback for start tags.
typedef void(* endElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
 SAX2 callback for end tags.
typedef xmlParserInput *(* xmlExternalEntityLoader) (const char *URL, const char *publicId, xmlParserCtxt *context)
 Callback for external entity loader.

Enumerations

enum  xmlParserStatus
 Status after parsing a document. More...
enum  xmlResourceType
 Resource type for resource loaders. More...
enum  xmlParserInputFlags
 Flags for parser input. More...
enum  xmlParserOption
 This is the set of XML parser options that can be passed to xmlReadDoc, xmlCtxtSetOptions and other functions. More...
enum  xmlFeature
 Used to examine the existence of features that can be enabled or disabled at compile-time. More...

Functions

void xmlInitParser (void)
 Initialization function for the XML parser.
void xmlCleanupParser (void)
 Free global memory allocations.
void xmlInitGlobals (void)
void xmlCleanupGlobals (void)
int xmlParserInputRead (xmlParserInput *in, int len)
int xmlParserInputGrow (xmlParserInput *in, int len)
 This function increase the input for the parser.
xmlDocxmlParseDoc (const xmlChar *cur)
 parse an XML in-memory document and build a tree.
xmlDocxmlParseFile (const char *filename)
 parse an XML file and build a tree.
xmlDocxmlParseMemory (const char *buffer, int size)
 parse an XML in-memory block and build a tree.
int xmlSubstituteEntitiesDefault (int val)
 Set and return the previous value for default entity support.
int xmlKeepBlanksDefault (int val)
 Set and return the previous value for default blanks text nodes support.
void xmlStopParser (xmlParserCtxt *ctxt)
 Blocks further parser processing.
int xmlPedanticParserDefault (int val)
 Set and return the previous value for enabling pedantic warnings.
int xmlLineNumbersDefault (int val)
 Has no effect.
int xmlThrDefSubstituteEntitiesDefaultValue (int v)
 Set per-thread default value.
int xmlThrDefKeepBlanksDefaultValue (int v)
 Set per-thread default value.
int xmlThrDefPedanticParserDefaultValue (int v)
 Set per-thread default value.
int xmlThrDefLineNumbersDefaultValue (int v)
 Set per-thread default value.
int xmlThrDefDoValidityCheckingDefaultValue (int v)
 Set per-thread default value.
int xmlThrDefGetWarningsDefaultValue (int v)
 Set per-thread default value.
int xmlThrDefLoadExtDtdDefaultValue (int v)
 Set per-thread default value.
xmlDocxmlRecoverDoc (const xmlChar *cur)
 parse an XML in-memory document and build a tree.
xmlDocxmlRecoverMemory (const char *buffer, int size)
 parse an XML in-memory block and build a tree.
xmlDocxmlRecoverFile (const char *filename)
 parse an XML file and build a tree.
int xmlParseDocument (xmlParserCtxt *ctxt)
 Parse an XML document and invoke the SAX handlers.
int xmlParseExtParsedEnt (xmlParserCtxt *ctxt)
 parse a general parsed entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.
int xmlSAXUserParseFile (xmlSAXHandler *sax, void *user_data, const char *filename)
 parse an XML file and call the given SAX handler routines.
int xmlSAXUserParseMemory (xmlSAXHandler *sax, void *user_data, const char *buffer, int size)
 parse an XML in-memory buffer and call the given SAX handler routines.
xmlDocxmlSAXParseDoc (xmlSAXHandler *sax, const xmlChar *cur, int recovery)
 parse an XML in-memory document and build a tree.
xmlDocxmlSAXParseMemory (xmlSAXHandler *sax, const char *buffer, int size, int recovery)
 parse an XML in-memory block and use the given SAX function block to handle the parsing callback.
xmlDocxmlSAXParseMemoryWithData (xmlSAXHandler *sax, const char *buffer, int size, int recovery, void *data)
 parse an XML in-memory block and use the given SAX function block to handle the parsing callback.
xmlDocxmlSAXParseFile (xmlSAXHandler *sax, const char *filename, int recovery)
 parse an XML file and build a tree.
xmlDocxmlSAXParseFileWithData (xmlSAXHandler *sax, const char *filename, int recovery, void *data)
 parse an XML file and build a tree.
xmlDocxmlSAXParseEntity (xmlSAXHandler *sax, const char *filename)
 parse an XML external entity out of context and build a tree.
xmlDocxmlParseEntity (const char *filename)
 parse an XML external entity out of context and build a tree.
xmlDtdxmlCtxtParseDtd (xmlParserCtxt *ctxt, xmlParserInput *input, const xmlChar *publicId, const xmlChar *systemId)
 Parse a DTD.
int xmlCtxtValidateDocument (xmlParserCtxt *ctxt, xmlDoc *doc)
 Validate a document.
int xmlCtxtValidateDtd (xmlParserCtxt *ctxt, xmlDoc *doc, xmlDtd *dtd)
 Validate a document against a DTD.
xmlDtdxmlSAXParseDTD (xmlSAXHandler *sax, const xmlChar *publicId, const xmlChar *systemId)
 Load and parse an external subset.
xmlDtdxmlParseDTD (const xmlChar *publicId, const xmlChar *systemId)
 Load and parse an external subset.
xmlDtdxmlIOParseDTD (xmlSAXHandler *sax, xmlParserInputBuffer *input, xmlCharEncoding enc)
 Load and parse a DTD.
int xmlParseBalancedChunkMemory (xmlDoc *doc, xmlSAXHandler *sax, void *user_data, int depth, const xmlChar *string, xmlNode **lst)
 Parse a well-balanced chunk of an XML document called by the parser The allowed sequence for the Well Balanced Chunk is the one defined by the content production in the XML grammar:
xmlParserErrors xmlParseInNodeContext (xmlNode *node, const char *data, int datalen, int options, xmlNode **lst)
 Parse a well-balanced chunk of an XML document within the context (DTD, namespaces, etc ...) of the given node.
int xmlParseBalancedChunkMemoryRecover (xmlDoc *doc, xmlSAXHandler *sax, void *user_data, int depth, const xmlChar *string, xmlNode **lst, int recover)
 Parse a well-balanced chunk of an XML document.
int xmlParseExternalEntity (xmlDoc *doc, xmlSAXHandler *sax, void *user_data, int depth, const xmlChar *URL, const xmlChar *ID, xmlNode **lst)
 Parse an external general entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.
int xmlParseCtxtExternalEntity (xmlParserCtxt *ctx, const xmlChar *URL, const xmlChar *ID, xmlNode **lst)
 Parse an external general entity within an existing parsing context An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.
xmlParserCtxtxmlNewParserCtxt (void)
 Allocate and initialize a new parser context.
xmlParserCtxtxmlNewSAXParserCtxt (const xmlSAXHandler *sax, void *userData)
 Allocate and initialize a new SAX parser context.
int xmlInitParserCtxt (xmlParserCtxt *ctxt)
 Initialize a parser context.
void xmlClearParserCtxt (xmlParserCtxt *ctxt)
 Same as xmlCtxtReset.
void xmlFreeParserCtxt (xmlParserCtxt *ctxt)
 Free all the memory used by a parser context.
void xmlSetupParserForBuffer (xmlParserCtxt *ctxt, const xmlChar *buffer, const char *filename)
 Setup the parser context to parse a new buffer; Clears any prior contents from the parser context.
xmlParserCtxtxmlCreateDocParserCtxt (const xmlChar *cur)
 Creates a parser context for an XML in-memory document.
xmlParserCtxtxmlCreatePushParserCtxt (xmlSAXHandler *sax, void *user_data, const char *chunk, int size, const char *filename)
 Create a parser context for using the XML parser in push mode.
int xmlParseChunk (xmlParserCtxt *ctxt, const char *chunk, int size, int terminate)
 Parse a chunk of memory in push parser mode.
xmlParserCtxtxmlCreateIOParserCtxt (xmlSAXHandler *sax, void *user_data, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
 Create a parser context for using the XML parser with an existing I/O stream.
xmlParserInputxmlNewIOInputStream (xmlParserCtxt *ctxt, xmlParserInputBuffer *input, xmlCharEncoding enc)
 Create a new input stream structure encapsulating the input into a stream suitable for the parser.
const xmlParserNodeInfo * xmlParserFindNodeInfo (xmlParserCtxt *ctxt, xmlNode *node)
 Find the parser node info struct for a given node.
void xmlInitNodeInfoSeq (xmlParserNodeInfoSeq *seq)
 Initialize (set to initial state) node info sequence.
void xmlClearNodeInfoSeq (xmlParserNodeInfoSeq *seq)
 Clear (release memory and reinitialize) node info sequence.
unsigned long xmlParserFindNodeInfoIndex (xmlParserNodeInfoSeq *seq, xmlNode *node)
 Find the index that the info record for the given node is or should be at in a sorted sequence.
void xmlParserAddNodeInfo (xmlParserCtxt *ctxt, xmlParserNodeInfo *info)
 Insert node info record into the sorted sequence.
void xmlSetExternalEntityLoader (xmlExternalEntityLoader f)
 Changes the default external entity resolver function for the application.
xmlExternalEntityLoader xmlGetExternalEntityLoader (void)
 Get the default external entity resolver function for the application.
xmlParserInputxmlLoadExternalEntity (const char *URL, const char *ID, xmlParserCtxt *ctxt)
 URL is a filename or URL.
long xmlByteConsumed (xmlParserCtxt *ctxt)
 This function provides the current index of the parser relative to the start of the current entity.
void xmlCtxtReset (xmlParserCtxt *ctxt)
 Reset a parser context.
int xmlCtxtResetPush (xmlParserCtxt *ctxt, const char *chunk, int size, const char *filename, const char *encoding)
 Reset a push parser context.
int xmlCtxtGetOptions (xmlParserCtxt *ctxt)
 Get the current options of the parser context.
int xmlCtxtSetOptions (xmlParserCtxt *ctxt, int options)
 Applies the options to the parser context.
int xmlCtxtUseOptions (xmlParserCtxt *ctxt, int options)
 Applies the options to the parser context.
void * xmlCtxtGetPrivate (xmlParserCtxt *ctxt)
void xmlCtxtSetPrivate (xmlParserCtxt *ctxt, void *priv)
 Set the private application data.
void * xmlCtxtGetCatalogs (xmlParserCtxt *ctxt)
void xmlCtxtSetCatalogs (xmlParserCtxt *ctxt, void *catalogs)
 Set the local catalogs.
xmlDict * xmlCtxtGetDict (xmlParserCtxt *ctxt)
void xmlCtxtSetDict (xmlParserCtxt *ctxt, xmlDict *)
 Set the dictionary.
xmlSAXHandlerxmlCtxtGetSaxHandler (xmlParserCtxt *ctxt)
int xmlCtxtSetSaxHandler (xmlParserCtxt *ctxt, const xmlSAXHandler *sax)
 Set the SAX handler struct to a copy of sax.
xmlDocxmlCtxtGetDocument (xmlParserCtxt *ctxt)
int xmlCtxtIsHtml (xmlParserCtxt *ctxt)
int xmlCtxtIsStopped (xmlParserCtxt *ctxt)
 Check whether the parser is stopped.
xmlValidCtxtxmlCtxtGetValidCtxt (xmlParserCtxt *ctxt)
const xmlCharxmlCtxtGetVersion (xmlParserCtxt *ctxt)
const xmlCharxmlCtxtGetDeclaredEncoding (xmlParserCtxt *ctxt)
int xmlCtxtGetStandalone (xmlParserCtxt *ctxt)
xmlParserStatus xmlCtxtGetStatus (xmlParserCtxt *ctxt)
 Get well-formedness and validation status after parsing.
void xmlCtxtSetErrorHandler (xmlParserCtxt *ctxt, xmlStructuredErrorFunc handler, void *data)
 Register a callback function that will be called on errors and warnings.
void xmlCtxtSetResourceLoader (xmlParserCtxt *ctxt, xmlResourceLoader loader, void *vctxt)
 Installs a custom callback to load documents, DTDs or external entities.
void xmlCtxtSetCharEncConvImpl (xmlParserCtxt *ctxt, xmlCharEncConvImpl impl, void *vctxt)
 Installs a custom implementation to convert between character encodings.
void xmlCtxtSetMaxAmplification (xmlParserCtxt *ctxt, unsigned maxAmpl)
 To protect against exponential entity expansion ("billion laughs"), the size of serialized output is (roughly) limited to the input size multiplied by this factor.
xmlDocxmlReadDoc (const xmlChar *cur, const char *URL, const char *encoding, int options)
 Convenience function to parse an XML document from a zero-terminated string.
xmlDocxmlReadFile (const char *URL, const char *encoding, int options)
 Convenience function to parse an XML file from the filesystem, the network or a global user-define resource loader.
xmlDocxmlReadMemory (const char *buffer, int size, const char *URL, const char *encoding, int options)
 Parse an XML in-memory document and build a tree.
xmlDocxmlReadFd (int fd, const char *URL, const char *encoding, int options)
 Parse an XML from a file descriptor and build a tree.
xmlDocxmlReadIO (xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
 Parse an XML document from I/O functions and context and build a tree.
xmlDocxmlCtxtParseDocument (xmlParserCtxt *ctxt, xmlParserInput *input)
 Parse an XML document and return the resulting document tree.
xmlNodexmlCtxtParseContent (xmlParserCtxt *ctxt, xmlParserInput *input, xmlNode *node, int hasTextDecl)
 Parse a well-balanced chunk of XML matching the 'content' production.
xmlDocxmlCtxtReadDoc (xmlParserCtxt *ctxt, const xmlChar *cur, const char *URL, const char *encoding, int options)
 Parse an XML in-memory document and build a tree.
xmlDocxmlCtxtReadFile (xmlParserCtxt *ctxt, const char *filename, const char *encoding, int options)
 Parse an XML file from the filesystem, the network or a user-defined resource loader.
xmlDocxmlCtxtReadMemory (xmlParserCtxt *ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options)
 Parse an XML in-memory document and build a tree.
xmlDocxmlCtxtReadFd (xmlParserCtxt *ctxt, int fd, const char *URL, const char *encoding, int options)
 Parse an XML document from a file descriptor and build a tree.
xmlDocxmlCtxtReadIO (xmlParserCtxt *ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
 parse an XML document from I/O functions and source and build a tree.
xmlParserErrors xmlNewInputFromUrl (const char *url, xmlParserInputFlags flags, xmlParserInput **out)
 Create a new input stream based on a file or a URL.
xmlParserInputxmlNewInputFromMemory (const char *url, const void *mem, size_t size, xmlParserInputFlags flags)
 Creates a new parser input to read from a memory area.
xmlParserInputxmlNewInputFromString (const char *url, const char *str, xmlParserInputFlags flags)
 Creates a new parser input to read from a zero-terminated string.
xmlParserInputxmlNewInputFromFd (const char *url, int fd, xmlParserInputFlags flags)
 Creates a new parser input to read from a file descriptor.
xmlParserInputxmlNewInputFromIO (const char *url, xmlInputReadCallback ioRead, xmlInputCloseCallback ioClose, void *ioCtxt, xmlParserInputFlags flags)
 Creates a new parser input to read from input callbacks and context.
xmlParserErrors xmlInputSetEncodingHandler (xmlParserInput *input, xmlCharEncodingHandler *handler)
 Use encoding handler to decode input data.
int xmlHasFeature (xmlFeature feature)
 Examines if the library has been compiled with a given feature.

Variables

const char *const xmlParserVersion
 Constant string describing the version of the library used at run-time.

Detailed Description

Validating XML 1.0 parser.

Interfaces, constants and types related to the XML parser.

Author
Daniel Veillard

Macro Definition Documentation

◆ xmlDoValidityCheckingDefaultValue

#define xmlDoValidityCheckingDefaultValue    (*__xmlDoValidityCheckingDefaultValue())

Thread-local setting to enable validation.

Defaults to 0.

Deprecated
Use the parser option XML_PARSE_DTDVALID.

◆ xmlGetWarningsDefaultValue

#define xmlGetWarningsDefaultValue    (*__xmlGetWarningsDefaultValue())

Thread-local setting to disable warnings.

Defaults to 1.

Deprecated
Use the parser option XML_PARSE_NOWARNING.

◆ xmlIndentTreeOutput

#define xmlIndentTreeOutput   (*__xmlIndentTreeOutput())

Thread-local setting to disable indenting when formatting output.

Defaults to 1.

Deprecated
Use the xmlsave.h API with option XML_SAVE_NO_INDENT.

◆ xmlKeepBlanksDefaultValue

#define xmlKeepBlanksDefaultValue   (*__xmlKeepBlanksDefaultValue())

Thread-local setting to ignore some whitespace.

Defaults to 1.

Deprecated
Use the parser option XML_PARSE_NOBLANKS.

◆ xmlLineNumbersDefaultValue

#define xmlLineNumbersDefaultValue    (*__xmlLineNumbersDefaultValue())

Thread-local setting to store line numbers.

Defaults to 0, but is always enabled after setting parser options.

Deprecated
Shouldn't be needed when using parser options.

◆ xmlLoadExtDtdDefaultValue

#define xmlLoadExtDtdDefaultValue   (*__xmlLoadExtDtdDefaultValue())

Thread-local setting to enable loading of external DTDs.

Defaults to 0.

Deprecated
Use the parser option XML_PARSE_DTDLOAD.

◆ xmlPedanticParserDefaultValue

#define xmlPedanticParserDefaultValue    (*__xmlPedanticParserDefaultValue())

Thread-local setting to enable pedantic warnings.

Defaults to 0.

Deprecated
Use the parser option XML_PARSE_PEDANTIC.

◆ xmlSaveNoEmptyTags

#define xmlSaveNoEmptyTags   (*__xmlSaveNoEmptyTags())

Thread-local setting to disable empty tags when serializing.

Defaults to 0.

Deprecated
Use the xmlsave.h API with option XML_SAVE_NO_EMPTY.

◆ xmlSubstituteEntitiesDefaultValue

#define xmlSubstituteEntitiesDefaultValue    (*__xmlSubstituteEntitiesDefaultValue())

Thread-local setting to enable entity substitution.

Defaults to 0.

Deprecated
Use the parser option XML_PARSE_NOENT.

◆ xmlTreeIndentString

#define xmlTreeIndentString   (*__xmlTreeIndentString())

Thread-local setting to change the indent string.

Defaults to two spaces.

Deprecated
Use the xmlsave.h API and xmlSaveSetIndentString().

Typedef Documentation

◆ attributeDeclSAXFunc

typedef void(* attributeDeclSAXFunc) (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumeration *tree)

SAX callback for attribute declarations.

Parameters
ctxthe user data (XML parser context)
elemthe name of the element
fullnamethe attribute name
typethe attribute type
defthe type of default value
defaultValuethe attribute default value
treethe tree of enumerated value set

◆ attributeSAXFunc

typedef void(* attributeSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *value)

Callback for attributes.

Deprecated
This typedef is unused.
Parameters
ctxthe user data (XML parser context)
nameThe attribute name, including namespace prefix
valueThe attribute value

◆ cdataBlockSAXFunc

typedef void(* cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len)

SAX callback for CDATA sections.

Parameters
ctxthe user data (XML parser context)
valueThe pcdata content
lenthe block length

◆ charactersSAXFunc

typedef void(* charactersSAXFunc) (void *ctx, const xmlChar *ch, int len)

SAX callback for character data.

Parameters
ctxthe user data (XML parser context)
cha xmlChar string
lenthe number of xmlChar

◆ commentSAXFunc

typedef void(* commentSAXFunc) (void *ctx, const xmlChar *value)

SAX callback for comments.

Parameters
ctxthe user data (XML parser context)
valuethe comment content

◆ elementDeclSAXFunc

typedef void(* elementDeclSAXFunc) (void *ctx, const xmlChar *name, int type, xmlElementContent *content)

SAX callback for element declarations.

Parameters
ctxthe user data (XML parser context)
namethe element name
typethe element type
contentthe element value tree

◆ endDocumentSAXFunc

typedef void(* endDocumentSAXFunc) (void *ctx)

SAX callback for end of document.

Parameters
ctxthe user data (XML parser context)

◆ endElementNsSAX2Func

typedef void(* endElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)

SAX2 callback for end tags.

It provides the namespace information for the element.

Parameters
ctxthe user data (XML parser context)
localnamethe local name of the element
prefixthe element namespace prefix if available
URIthe element namespace name if available

◆ endElementSAXFunc

typedef void(* endElementSAXFunc) (void *ctx, const xmlChar *name)

SAX callback for end tags.

Parameters
ctxthe user data (XML parser context)
nameThe element name

◆ entityDeclSAXFunc

typedef void(* entityDeclSAXFunc) (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)

SAX callback for entity declarations.

Parameters
ctxthe user data (XML parser context)
namethe entity name
typethe entity type
publicIdThe public ID of the entity
systemIdThe system ID of the entity
contentthe entity value (without processing).

◆ errorSAXFunc

typedef void(* errorSAXFunc) (void *ctx, const char *msg,...)

SAX callback for error messages.

Parameters
ctxan XML parser context
msgthe message to display/transmit
...extra parameters for the message display

◆ externalSubsetSAXFunc

typedef void(* externalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)

SAX callback for the external subset.

Parameters
ctxthe user data (XML parser context)
namethe root element name
publicIdthe public identifier
systemIdthe system identifier (e.g. filename or URL)

◆ fatalErrorSAXFunc

typedef void(* fatalErrorSAXFunc) (void *ctx, const char *msg,...)

SAX callback for fatal error messages.

Parameters
ctxan XML parser context
msgthe message to display/transmit
...extra parameters for the message display

◆ getEntitySAXFunc

typedef xmlEntity *(* getEntitySAXFunc) (void *ctx, const xmlChar *name)

SAX callback to look up a general entity by name.

Parameters
ctxthe user data (XML parser context)
nameThe entity name
Returns
the xmlEntity if found.

◆ getParameterEntitySAXFunc

typedef xmlEntity *(* getParameterEntitySAXFunc) (void *ctx, const xmlChar *name)

SAX callback to look up a parameter entity by name.

Parameters
ctxthe user data (XML parser context)
nameThe entity name
Returns
the xmlEntity if found.

◆ hasExternalSubsetSAXFunc

typedef int(* hasExternalSubsetSAXFunc) (void *ctx)

SAX callback to get external subset status.

Parameters
ctxthe user data (XML parser context)
Returns
1 if true

◆ hasInternalSubsetSAXFunc

typedef int(* hasInternalSubsetSAXFunc) (void *ctx)

SAX callback to get internal subset status.

Parameters
ctxthe user data (XML parser context)
Returns
1 if true

◆ ignorableWhitespaceSAXFunc

typedef void(* ignorableWhitespaceSAXFunc) (void *ctx, const xmlChar *ch, int len)

SAX callback for "ignorable" whitespace.

Parameters
ctxthe user data (XML parser context)
cha xmlChar string
lenthe number of xmlChar

◆ internalSubsetSAXFunc

typedef void(* internalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)

SAX callback for the internal subset.

Parameters
ctxthe user data (XML parser context)
namethe root element name
publicIdthe public identifier
systemIdthe system identifier (e.g. filename or URL)

◆ isStandaloneSAXFunc

typedef int(* isStandaloneSAXFunc) (void *ctx)

SAX callback to get standalone status.

Parameters
ctxthe user data (XML parser context)
Returns
1 if true

◆ notationDeclSAXFunc

typedef void(* notationDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)

SAX callback for notation declarations.

Parameters
ctxthe user data (XML parser context)
nameThe name of the notation
publicIdThe public ID of the notation
systemIdThe system ID of the notation

◆ processingInstructionSAXFunc

typedef void(* processingInstructionSAXFunc) (void *ctx, const xmlChar *target, const xmlChar *data)

SAX callback for processing instructions.

Parameters
ctxthe user data (XML parser context)
targetthe target name
datathe PI data's

◆ referenceSAXFunc

typedef void(* referenceSAXFunc) (void *ctx, const xmlChar *name)

SAX callback for entity references.

Parameters
ctxthe user data (XML parser context)
nameThe entity name

◆ resolveEntitySAXFunc

typedef xmlParserInput *(* resolveEntitySAXFunc) (void *ctx, const xmlChar *publicId, const xmlChar *systemId)

SAX callback to resolve external entities.

This is only used to load DTDs. The preferred way to install custom resolvers is xmlCtxtSetResourceLoader.

Parameters
ctxthe user data (XML parser context)
publicIdThe public identifier of the entity
systemIdThe system identifier of the entity (URL)
Returns
the xmlParserInput if inlined or NULL for DOM behaviour.

◆ setDocumentLocatorSAXFunc

typedef void(* setDocumentLocatorSAXFunc) (void *ctx, xmlSAXLocator *loc)

This callback receives the "document locator" at startup, which is always the global xmlDefaultSAXLocator.

Everything is available on the context, so this is useless in our case.

Parameters
ctxthe user data (XML parser context)
locA SAX Locator

◆ startDocumentSAXFunc

typedef void(* startDocumentSAXFunc) (void *ctx)

SAX callback for start of document.

Parameters
ctxthe user data (XML parser context)

◆ startElementNsSAX2Func

typedef void(* startElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes)

SAX2 callback for start tags.

It provides the namespace information for the element, as well as the new namespace declarations on the element.

Parameters
ctxthe user data (XML parser context)
localnamethe local name of the element
prefixthe element namespace prefix if available
URIthe element namespace name if available
nb_namespacesnumber of namespace definitions on that node
namespacespointer to the array of prefix/URI pairs namespace definitions
nb_attributesthe number of attributes on that node
nb_defaultedthe number of defaulted attributes. The defaulted ones are at the end of the array
attributespointer to the array of (localname/prefix/URI/value/end) attribute values.

◆ startElementSAXFunc

typedef void(* startElementSAXFunc) (void *ctx, const xmlChar *name, const xmlChar **atts)

SAX callback for start tags.

Parameters
ctxthe user data (XML parser context)
nameThe element name, including namespace prefix
attsAn array of name/value attributes pairs, NULL terminated

◆ unparsedEntityDeclSAXFunc

typedef void(* unparsedEntityDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName)

SAX callback for unparsed entity declarations.

Parameters
ctxthe user data (XML parser context)
nameThe name of the entity
publicIdThe public ID of the entity
systemIdThe system ID of the entity
notationNamethe name of the notation

◆ warningSAXFunc

typedef void(* warningSAXFunc) (void *ctx, const char *msg,...)

SAX callback for warning messages.

Parameters
ctxan XML parser context
msgthe message to display/transmit
...extra parameters for the message display

◆ xmlExternalEntityLoader

typedef xmlParserInput *(* xmlExternalEntityLoader) (const char *URL, const char *publicId, xmlParserCtxt *context)

Callback for external entity loader.

The URL is not resolved using XML catalogs before being passed to the callback.

Parameters
URLThe URL or system ID of the resource requested
publicIdThe public ID of the resource requested (optional)
contextthe XML parser context
Returns
the entity input parser or NULL on error.

◆ xmlResourceLoader

typedef xmlParserErrors(* xmlResourceLoader) (void *ctxt, const char *url, const char *publicId, xmlResourceType type, xmlParserInputFlags flags, xmlParserInput **out)

Callback for custom resource loaders.

flags can contain XML_INPUT_UNZIP and XML_INPUT_NETWORK.

The URL is resolved using XML catalogs before being passed to the callback.

On success, out should be set to a new parser input object and XML_ERR_OK should be returned.

Parameters
ctxtparser context
urlURL or system ID to load
publicIdpublid ID from DTD (optional)
typeresource type
flagsflags
outresult pointer
Returns
an xmlParserErrors code.

Enumeration Type Documentation

◆ xmlFeature

enum xmlFeature

Used to examine the existence of features that can be enabled or disabled at compile-time.

They used to be called XML_FEATURE_xxx but this clashed with Expat

Enumerator
XML_WITH_THREAD 

Multithreading support.

XML_WITH_TREE 
Deprecated
Always available
XML_WITH_OUTPUT 

Serialization support.

XML_WITH_PUSH 

Push parser.

XML_WITH_READER 

XML Reader.

XML_WITH_PATTERN 

Streaming patterns.

XML_WITH_WRITER 

XML Writer.

XML_WITH_SAX1 

Legacy SAX1 API.

XML_WITH_FTP 
Deprecated
FTP support was removed
XML_WITH_HTTP 
Deprecated
HTTP support was removed
XML_WITH_VALID 

DTD validation.

XML_WITH_HTML 

HTML parser.

XML_WITH_LEGACY 

Legacy symbols.

XML_WITH_C14N 

Canonical XML.

XML_WITH_CATALOG 

XML Catalogs.

XML_WITH_XPATH 

XPath.

XML_WITH_XPTR 

XPointer.

XML_WITH_XINCLUDE 

XInclude.

XML_WITH_ICONV 

iconv

XML_WITH_ISO8859X 

Built-in ISO-8859-X.

XML_WITH_UNICODE 
Deprecated
Removed
XML_WITH_REGEXP 

Regular expressions.

XML_WITH_AUTOMATA 
Deprecated
Same as XML_WITH_REGEXP
XML_WITH_EXPR 
Deprecated
Removed
XML_WITH_SCHEMAS 

XML Schemas.

XML_WITH_SCHEMATRON 

Schematron.

XML_WITH_MODULES 

Loadable modules.

XML_WITH_DEBUG 

Debugging API.

XML_WITH_DEBUG_MEM 
Deprecated
Removed
XML_WITH_DEBUG_RUN 
Deprecated
Removed
XML_WITH_ZLIB 

GZIP compression.

XML_WITH_ICU 

ICU.

XML_WITH_LZMA 

LZMA compression.

XML_WITH_RELAXNG 

RELAXNG, since 2.14.

◆ xmlParserInputFlags

Flags for parser input.

Enumerator
XML_INPUT_BUF_STATIC 

The input buffer won't be changed during parsing.

XML_INPUT_BUF_ZERO_TERMINATED 

The input buffer is zero-terminated.

(Note that the zero byte shouldn't be included in buffer size.)

XML_INPUT_UNZIP 

Uncompress gzipped file input.

XML_INPUT_NETWORK 

Allow network access.

Unused internally.

XML_INPUT_USE_SYS_CATALOG 

Allow system catalog to resolve URIs.

◆ xmlParserOption

This is the set of XML parser options that can be passed to xmlReadDoc, xmlCtxtSetOptions and other functions.

Enumerator
XML_PARSE_RECOVER 

Enable "recovery" mode which allows non-wellformed documents.

How this mode behaves exactly is unspecified and may change without further notice. Use of this feature is DISCOURAGED.

Not supported by the push parser.

XML_PARSE_NOENT 

Despite the confusing name, this option enables substitution of entities.

The resulting tree won't contain any entity reference nodes.

This option also enables loading of external entities (both general and parameter entities) which is dangerous. If you process untrusted data, it's recommended to set the XML_PARSE_NO_XXE option to disable loading of external entities.

XML_PARSE_DTDLOAD 

Enables loading of an external DTD and the loading and substitution of external parameter entities.

Has no effect if XML_PARSE_NO_XXE is set.

XML_PARSE_DTDATTR 

Adds default attributes from the DTD to the result document.

Implies XML_PARSE_DTDLOAD, but loading of external content can be disabled with XML_PARSE_NO_XXE.

XML_PARSE_DTDVALID 

This option enables DTD validation which requires to load external DTDs and external entities (both general and parameter entities) unless XML_PARSE_NO_XXE was set.

XML_PARSE_NOERROR 

Disable error and warning reports to the error handlers.

Errors are still accessible with xmlCtxtGetLastError().

XML_PARSE_NOWARNING 

Disable warning reports.

XML_PARSE_PEDANTIC 

Enable some pedantic warnings.

XML_PARSE_NOBLANKS 

Remove some whitespace from the result document.

Where to remove whitespace depends on DTD element declarations or a broken heuristic with unfixable bugs. Use of this option is DISCOURAGED.

Not supported by the push parser.

XML_PARSE_SAX1 

Always invoke the deprecated SAX1 startElement and endElement handlers.

Deprecated
This option will be removed in a future version.
XML_PARSE_XINCLUDE 

Enable XInclude processing.

This option only affects the xmlTextReader and XInclude interfaces.

XML_PARSE_NONET 

Disable network access with the built-in HTTP or FTP clients.

After the last built-in network client was removed in 2.15, this option has no effect expect for being passed on to custom resource loaders.

XML_PARSE_NODICT 

Create a document without interned strings, making all strings separate memory allocations.

XML_PARSE_NSCLEAN 

Remove redundant namespace declarations from the result document.

XML_PARSE_NOCDATA 

Output normal text nodes instead of CDATA nodes.

XML_PARSE_NOXINCNODE 

Don't generate XInclude start/end nodes when expanding inclusions.

This option only affects the xmlTextReader and XInclude interfaces.

XML_PARSE_COMPACT 

Store small strings directly in the node struct to save memory.

XML_PARSE_OLD10 

Use old Name productions from before XML 1.0 Fifth Edition.

Deprecated
This option will be removed in a future version.
XML_PARSE_NOBASEFIX 

Don't fix up XInclude xml:base URIs.

This option only affects the xmlTextReader and XInclude interfaces.

XML_PARSE_HUGE 

Relax some internal limits.

Maximum size of text nodes, tags, comments, processing instructions, CDATA sections, entity values

normal: 10M huge: 1B

Maximum size of names, system literals, pubid literals

normal: 50K huge: 10M

Maximum nesting depth of elements

normal: 256 huge: 2048

Maximum nesting depth of entities

normal: 20 huge: 40

XML_PARSE_OLDSAX 

Enable an unspecified legacy mode for SAX parsers.

Deprecated
This option will be removed in a future version.
XML_PARSE_IGNORE_ENC 

Ignore the encoding in the XML declaration.

This option is mostly unneeded these days. The only effect is to enforce UTF-8 decoding of ASCII-like data.

XML_PARSE_BIG_LINES 

Enable reporting of line numbers larger than 65535.

XML_PARSE_NO_XXE 

Disables loading of external DTDs or entities.

Since
2.13.0
XML_PARSE_UNZIP 

Enable input decompression.

Setting this option is discouraged to avoid zip bombs.

Since
2.14.0
XML_PARSE_NO_SYS_CATALOG 

Disables the global system XML catalog.

Since
2.14.0
XML_PARSE_CATALOG_PI 

Enable XML catalog processing instructions.

Since
2.14.0
XML_PARSE_SKIP_IDS 

Force the parser to ignore IDs.

Since
2.15.0

◆ xmlParserStatus

Status after parsing a document.

Enumerator
XML_STATUS_NOT_WELL_FORMED 

not well-formed

XML_STATUS_NOT_NS_WELL_FORMED 

not namespace-well-formed

XML_STATUS_DTD_VALIDATION_FAILED 

DTD validation failed.

XML_STATUS_CATASTROPHIC_ERROR 

catastrophic failure like OOM or I/O error

◆ xmlResourceType

Resource type for resource loaders.

Enumerator
XML_RESOURCE_UNKNOWN 

unknown

XML_RESOURCE_MAIN_DOCUMENT 

main document

XML_RESOURCE_DTD 

external DTD

XML_RESOURCE_GENERAL_ENTITY 

external general entity

XML_RESOURCE_PARAMETER_ENTITY 

external parameter entity

XML_RESOURCE_XINCLUDE 

XIncluded document.

XML_RESOURCE_XINCLUDE_TEXT 

XIncluded text.

Function Documentation

◆ xmlByteConsumed()

long xmlByteConsumed ( xmlParserCtxt * ctxt)

This function provides the current index of the parser relative to the start of the current entity.

This function is computed in bytes from the beginning starting at zero and finishing at the size in byte of the file if parsing a file. The function is of constant cost if the input is UTF-8 but can be costly if run on non-UTF-8 input.

Deprecated
Don't use.
Parameters
ctxtan XML parser context
Returns
the index in bytes from the beginning of the entity or -1 in case the index could not be computed.

◆ xmlCleanupGlobals()

void xmlCleanupGlobals ( void )
Deprecated
This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.

◆ xmlCleanupParser()

void xmlCleanupParser ( void )

Free global memory allocations.

This function is named somewhat misleadingly. It does not clean up parser state but frees global memory allocated by various components of the library.

Since 2.9.11, cleanup is performed automatically on most platforms and there's no need at all for manual cleanup. This includes all compilers and platforms that support GCC-style destructor attributes as well as Windows DLLs.

This function should only be used to avoid false positives from memory leak checkers if automatic cleanup isn't possible, for example with static builds on MSVC.

WARNING: xmlCleanupParser is not thread-safe. If this function is called and any threads that could make calls into libxml2 are still running, memory corruption is likely to occur.

No library calls must be made (from any thread) after calling this function. In general, this function should only be called right before the whole process exits. Calling this function too early will lead to memory corruption.

◆ xmlClearNodeInfoSeq()

void xmlClearNodeInfoSeq ( xmlParserNodeInfoSeq * seq)

Clear (release memory and reinitialize) node info sequence.

Deprecated
Don't use.
Parameters
seqa node info sequence pointer

◆ xmlClearParserCtxt()

void xmlClearParserCtxt ( xmlParserCtxt * ctxt)

Same as xmlCtxtReset.

Deprecated
Use xmlCtxtReset
Parameters
ctxtan XML parser context

◆ xmlCreateDocParserCtxt()

xmlParserCtxt * xmlCreateDocParserCtxt ( const xmlChar * str)

Creates a parser context for an XML in-memory document.

Parameters
stra pointer to an array of xmlChar
Returns
the new parser context or NULL

◆ xmlCreateIOParserCtxt()

xmlParserCtxt * xmlCreateIOParserCtxt ( xmlSAXHandler * sax,
void * user_data,
xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose,
void * ioctx,
xmlCharEncoding enc )

Create a parser context for using the XML parser with an existing I/O stream.

Parameters
saxa SAX handler (optional)
user_datauser data for SAX callbacks (optional)
ioreadan I/O read function
ioclosean I/O close function (optional)
ioctxan I/O handler
encthe charset encoding if known (deprecated)
Returns
the new parser context or NULL

◆ xmlCreatePushParserCtxt()

xmlParserCtxt * xmlCreatePushParserCtxt ( xmlSAXHandler * sax,
void * user_data,
const char * chunk,
int size,
const char * filename )

Create a parser context for using the XML parser in push mode.

See xmlParseChunk.

Passing an initial chunk is useless and deprecated.

The push parser doesn't support recovery mode or the XML_PARSE_NOBLANKS option.

filename is used as base URI to fetch external entities and for error reports.

Parameters
saxa SAX handler (optional)
user_datauser data for SAX callbacks (optional)
chunkinitial chunk (optional, deprecated)
sizesize of initial chunk in bytes
filenamefile name or URI (optional)
Returns
the new parser context or NULL if a memory allocation failed.

◆ xmlCtxtGetCatalogs()

void * xmlCtxtGetCatalogs ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the local catalogs.

◆ xmlCtxtGetDeclaredEncoding()

const xmlChar * xmlCtxtGetDeclaredEncoding ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the encoding from the encoding declaration. This can differ from the actual encoding.

◆ xmlCtxtGetDict()

xmlDict * xmlCtxtGetDict ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the dictionary.

◆ xmlCtxtGetDocument()

xmlDoc * xmlCtxtGetDocument ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the parsed document or NULL if a fatal error occurred when parsing. The document must be freed by the caller. Resets the context's document to NULL.

◆ xmlCtxtGetOptions()

int xmlCtxtGetOptions ( xmlParserCtxt * ctxt)

Get the current options of the parser context.

Since
2.14.0
Parameters
ctxtan XML parser context
Returns
the current options set in the parser context, or -1 if ctxt is NULL.

◆ xmlCtxtGetPrivate()

void * xmlCtxtGetPrivate ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the private application data.

◆ xmlCtxtGetSaxHandler()

xmlSAXHandler * xmlCtxtGetSaxHandler ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the SAX handler struct. This is not a copy and must not be freed. Handlers can be updated.

◆ xmlCtxtGetStandalone()

int xmlCtxtGetStandalone ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the value from the standalone document declaration.

◆ xmlCtxtGetStatus()

xmlParserStatus xmlCtxtGetStatus ( xmlParserCtxt * ctxt)

Get well-formedness and validation status after parsing.

Also reports catastrophic errors which are not related to parsing like out-of-memory, I/O or other errors.

Since
2.14.0
Parameters
ctxtan XML parser context
Returns
a bitmask of XML_STATUS_* flags ORed together.

◆ xmlCtxtGetValidCtxt()

xmlValidCtxt * xmlCtxtGetValidCtxt ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the validation context.

◆ xmlCtxtGetVersion()

const xmlChar * xmlCtxtGetVersion ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
the version from the XML declaration.

◆ xmlCtxtIsHtml()

int xmlCtxtIsHtml ( xmlParserCtxt * ctxt)
Since
2.14.0
Parameters
ctxtparser context
Returns
1 if this is a HTML parser context, 0 otherwise.

◆ xmlCtxtIsStopped()

int xmlCtxtIsStopped ( xmlParserCtxt * ctxt)

Check whether the parser is stopped.

The parser is stopped on fatal (non-wellformedness) errors or on user request with xmlStopParser.

Since
2.14.0
Parameters
ctxtparser context
Returns
1 if the parser is stopped, 0 otherwise.

◆ xmlCtxtParseContent()

xmlNode * xmlCtxtParseContent ( xmlParserCtxt * ctxt,
xmlParserInput * input,
xmlNode * node,
int hasTextDecl )

Parse a well-balanced chunk of XML matching the 'content' production.

Namespaces in scope of node and entities of node's document are recognized. When validating, the DTD of node's document is used.

Always consumes input even in error case.

Since
2.14.0
Parameters
ctxtparser context
inputparser input
nodetarget node or document
hasTextDeclwhether to parse text declaration
Returns
a node list or NULL in case of error.

◆ xmlCtxtParseDocument()

xmlDoc * xmlCtxtParseDocument ( xmlParserCtxt * ctxt,
xmlParserInput * input )

Parse an XML document and return the resulting document tree.

Takes ownership of the input object.

Since
2.13.0
Parameters
ctxtan XML parser context
inputparser input
Returns
the resulting document tree or NULL

◆ xmlCtxtParseDtd()

xmlDtd * xmlCtxtParseDtd ( xmlParserCtxt * ctxt,
xmlParserInput * input,
const xmlChar * publicId,
const xmlChar * systemId )

Parse a DTD.

Option XML_PARSE_DTDLOAD should be enabled in the parser context to make external entities work.

Since
2.14.0
Parameters
ctxta parser context
inputa parser input
publicIdpublic ID of the DTD (optional)
systemIdsystem ID of the DTD (optional)
Returns
the resulting xmlDtd or NULL in case of error. input will be freed by the function in any case.

◆ xmlCtxtReadDoc()

xmlDoc * xmlCtxtReadDoc ( xmlParserCtxt * ctxt,
const xmlChar * str,
const char * URL,
const char * encoding,
int options )

Parse an XML in-memory document and build a tree.

URL is used as base to resolve external entities and for error reporting.

See xmlCtxtUseOptions for details.

Parameters
ctxtan XML parser context
stra pointer to a zero terminated string
URLbase URL (optional)
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlCtxtReadFd()

xmlDoc * xmlCtxtReadFd ( xmlParserCtxt * ctxt,
int fd,
const char * URL,
const char * encoding,
int options )

Parse an XML document from a file descriptor and build a tree.

NOTE that the file descriptor will not be closed when the context is freed or reset.

URL is used as base to resolve external entities and for error reporting.

See xmlCtxtUseOptions for details.

Parameters
ctxtan XML parser context
fdan open file descriptor
URLbase URL (optional)
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlCtxtReadFile()

xmlDoc * xmlCtxtReadFile ( xmlParserCtxt * ctxt,
const char * filename,
const char * encoding,
int options )

Parse an XML file from the filesystem, the network or a user-defined resource loader.

This function always enables the XML_PARSE_UNZIP option for backward compatibility. This feature is potentially insecure and might be removed from later versions.

Parameters
ctxtan XML parser context
filenamea file or URL
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlCtxtReadIO()

xmlDoc * xmlCtxtReadIO ( xmlParserCtxt * ctxt,
xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose,
void * ioctx,
const char * URL,
const char * encoding,
int options )

parse an XML document from I/O functions and source and build a tree.

This reuses the existing ctxt parser context

URL is used as base to resolve external entities and for error reporting.

See xmlCtxtUseOptions for details.

Parameters
ctxtan XML parser context
ioreadan I/O read function
ioclosean I/O close function
ioctxan I/O handler
URLthe base URL to use for the document
encodingthe document encoding, or NULL
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlCtxtReadMemory()

xmlDoc * xmlCtxtReadMemory ( xmlParserCtxt * ctxt,
const char * buffer,
int size,
const char * URL,
const char * encoding,
int options )

Parse an XML in-memory document and build a tree.

The input buffer must not contain a terminating null byte.

URL is used as base to resolve external entities and for error reporting.

See xmlCtxtUseOptions for details.

Parameters
ctxtan XML parser context
buffera pointer to a char array
sizethe size of the array
URLbase URL (optional)
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlCtxtReset()

void xmlCtxtReset ( xmlParserCtxt * ctxt)

Reset a parser context.

Parameters
ctxtan XML parser context

◆ xmlCtxtResetPush()

int xmlCtxtResetPush ( xmlParserCtxt * ctxt,
const char * chunk,
int size,
const char * filename,
const char * encoding )

Reset a push parser context.

Parameters
ctxtan XML parser context
chunka pointer to an array of chars
sizenumber of chars in the array
filenamean optional file name or URI
encodingthe document encoding, or NULL
Returns
0 in case of success and 1 in case of error

◆ xmlCtxtSetCatalogs()

void xmlCtxtSetCatalogs ( xmlParserCtxt * ctxt,
void * catalogs )

Set the local catalogs.

Since
2.14.0
Parameters
ctxtparser context
catalogscatalogs pointer

◆ xmlCtxtSetCharEncConvImpl()

void xmlCtxtSetCharEncConvImpl ( xmlParserCtxt * ctxt,
xmlCharEncConvImpl impl,
void * vctxt )

Installs a custom implementation to convert between character encodings.

This bypasses legacy feature like global encoding handlers or encoding aliases.

Since
2.14.0
Parameters
ctxtparser context
implcallback
vctxtuser data

◆ xmlCtxtSetDict()

void xmlCtxtSetDict ( xmlParserCtxt * ctxt,
xmlDict * dict )

Set the dictionary.

This should only be done immediately after creating a parser context.

Since
2.14.0
Parameters
ctxtparser context
dictdictionary

◆ xmlCtxtSetErrorHandler()

void xmlCtxtSetErrorHandler ( xmlParserCtxt * ctxt,
xmlStructuredErrorFunc handler,
void * data )

Register a callback function that will be called on errors and warnings.

If handler is NULL, the error handler will be deactivated.

This is the recommended way to collect errors from the parser and takes precedence over all other error reporting mechanisms. These are (in order of precedence):

Since
2.13.0
Parameters
ctxtan XML parser context
handlererror handler
datadata for error handler

◆ xmlCtxtSetMaxAmplification()

void xmlCtxtSetMaxAmplification ( xmlParserCtxt * ctxt,
unsigned maxAmpl )

To protect against exponential entity expansion ("billion laughs"), the size of serialized output is (roughly) limited to the input size multiplied by this factor.

The default value is 5.

When working with documents making heavy use of entity expansion, it can be necessary to increase the value. For security reasons, this should only be considered when processing trusted input.

Parameters
ctxtan XML parser context
maxAmplmaximum amplification factor

◆ xmlCtxtSetOptions()

int xmlCtxtSetOptions ( xmlParserCtxt * ctxt,
int options )

Applies the options to the parser context.

Unset options are cleared.

Since
2.13.0

With older versions, you can use xmlCtxtUseOptions.

Parameters
ctxtan XML parser context
optionsa bitmask of xmlParserOption values
Returns
0 in case of success, the set of unknown or unimplemented options in case of error.

◆ xmlCtxtSetPrivate()

void xmlCtxtSetPrivate ( xmlParserCtxt * ctxt,
void * priv )

Set the private application data.

Since
2.14.0
Parameters
ctxtparser context
privprivate application data

◆ xmlCtxtSetResourceLoader()

void xmlCtxtSetResourceLoader ( xmlParserCtxt * ctxt,
xmlResourceLoader loader,
void * vctxt )

Installs a custom callback to load documents, DTDs or external entities.

If vctxt is NULL, the parser context will be passed.

Since
2.14.0
Parameters
ctxtparser context
loadercallback
vctxtuser data (optional)

◆ xmlCtxtSetSaxHandler()

int xmlCtxtSetSaxHandler ( xmlParserCtxt * ctxt,
const xmlSAXHandler * sax )

Set the SAX handler struct to a copy of sax.

Since
2.14.0
Parameters
ctxtparser context
saxSAX handler
Returns
0 on success or -1 if arguments are invalid or a memory allocation failed.

◆ xmlCtxtUseOptions()

int xmlCtxtUseOptions ( xmlParserCtxt * ctxt,
int options )

Applies the options to the parser context.

The following options are never cleared and can only be enabled:

Deprecated
Use xmlCtxtSetOptions.
  • XML_PARSE_NOERROR
  • XML_PARSE_NOWARNING
  • XML_PARSE_NONET
  • XML_PARSE_NSCLEAN
  • XML_PARSE_NOCDATA
  • XML_PARSE_COMPACT
  • XML_PARSE_OLD10
  • XML_PARSE_HUGE
  • XML_PARSE_OLDSA- X
  • XML_PARSE_IGNORE_ENC
  • XML_PARSE_BIG_LINES
Parameters
ctxtan XML parser context
optionsa combination of xmlParserOption
Returns
0 in case of success, the set of unknown or unimplemented options in case of error.

◆ xmlCtxtValidateDocument()

int xmlCtxtValidateDocument ( xmlParserCtxt * ctxt,
xmlDoc * doc )

Validate a document.

Like xmlValidateDocument but uses the parser context's error handler.

Option XML_PARSE_DTDLOAD should be enabled in the parser context to make external entities work.

Since
2.14.0
Parameters
ctxta parser context
doca document instance
Returns
1 if valid or 0 otherwise.

◆ xmlCtxtValidateDtd()

int xmlCtxtValidateDtd ( xmlParserCtxt * ctxt,
xmlDoc * doc,
xmlDtd * dtd )

Validate a document against a DTD.

Like xmlValidateDtd but uses the parser context's error handler.

Since
2.14.0
Parameters
ctxta parser context
doca document instance
dtda dtd instance
Returns
1 if valid or 0 otherwise.

◆ xmlFreeParserCtxt()

void xmlFreeParserCtxt ( xmlParserCtxt * ctxt)

Free all the memory used by a parser context.

However the parsed document in ctxt->myDoc is not freed.

Parameters
ctxtan XML parser context

◆ xmlGetExternalEntityLoader()

xmlExternalEntityLoader xmlGetExternalEntityLoader ( void )

Get the default external entity resolver function for the application.

Deprecated
See xmlSetExternalEntityLoader.
Returns
the xmlExternalEntityLoader function pointer

◆ xmlHasFeature()

int xmlHasFeature ( xmlFeature feature)

Examines if the library has been compiled with a given feature.

Parameters
featurethe feature to be examined
Returns
zero (0) if the feature does not exist or an unknown feature is requested, non-zero otherwise.

◆ xmlInitGlobals()

void xmlInitGlobals ( void )

◆ xmlInitNodeInfoSeq()

void xmlInitNodeInfoSeq ( xmlParserNodeInfoSeq * seq)

Initialize (set to initial state) node info sequence.

Deprecated
Don't use.
Parameters
seqa node info sequence pointer

◆ xmlInitParser()

void xmlInitParser ( void )

Initialization function for the XML parser.

For older versions, it's recommended to call this function once from the main thread before using the library in multithreaded programs.

Since 2.14.0, there's no distinction between threads. It should be unnecessary to call this function.

◆ xmlInitParserCtxt()

int xmlInitParserCtxt ( xmlParserCtxt * ctxt)

Initialize a parser context.

Deprecated
Internal function which will be made private in a future version.
Parameters
ctxtan XML parser context
Returns
0 in case of success and -1 in case of error

◆ xmlInputSetEncodingHandler()

xmlParserErrors xmlInputSetEncodingHandler ( xmlParserInput * input,
xmlCharEncodingHandler * handler )

Use encoding handler to decode input data.

Closes the handler on error.

Parameters
inputthe input stream
handlerthe encoding handler
Returns
an xmlParserErrors code.

◆ xmlIOParseDTD()

xmlDtd * xmlIOParseDTD ( xmlSAXHandler * sax,
xmlParserInputBuffer * input,
xmlCharEncoding enc )

Load and parse a DTD.

Deprecated
Use xmlCtxtParseDtd.
Parameters
saxthe SAX handler block or NULL
inputan Input Buffer
encthe charset encoding if known
Returns
the resulting xmlDtd or NULL in case of error. input will be freed by the function in any case.

◆ xmlKeepBlanksDefault()

int xmlKeepBlanksDefault ( int val)

Set and return the previous value for default blanks text nodes support.

Deprecated
Use the modern options API with XML_PARSE_NOBLANKS.
Parameters
valint 0 or 1
Returns
the last value for 0 for no substitution, 1 for substitution.

◆ xmlLineNumbersDefault()

int xmlLineNumbersDefault ( int val)

Has no effect.

Deprecated
Line numbers are always enabled.
Parameters
valint 0 or 1
Returns
1

◆ xmlLoadExternalEntity()

xmlParserInput * xmlLoadExternalEntity ( const char * URL,
const char * publicId,
xmlParserCtxt * ctxt )

URL is a filename or URL.

If if contains the substring "://", it is assumed to be a Legacy Extended IRI. Otherwise, it is treated as a filesystem path.

publicId is an optional XML public ID, typically from a doctype declaration. It is used for catalog lookups.

If catalog lookup is enabled (default is yes) and URL or ID are found in system or local XML catalogs, URL is replaced with the result. Then the following resource loaders will be called if they were registered (in order of precedence):

Parameters
URLthe URL or system ID for the entity to load
publicIdthe public ID for the entity to load (optional)
ctxtthe context in which the entity is called or NULL
Returns
the xmlParserInput or NULL

◆ xmlNewInputFromFd()

xmlParserInput * xmlNewInputFromFd ( const char * url,
int fd,
xmlParserInputFlags flags )

Creates a new parser input to read from a file descriptor.

url is used as base to resolve external entities and for error reporting.

fd is closed after parsing has finished.

Supported flags are XML_INPUT_UNZIP to decompress data automatically. This feature is deprecated and will be removed in a future release.

Since
2.14.0
Parameters
urlbase URL (optional)
fdfile descriptor
flagsinput flags
Returns
a new parser input or NULL if a memory allocation failed.

◆ xmlNewInputFromIO()

xmlParserInput * xmlNewInputFromIO ( const char * url,
xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose,
void * ioCtxt,
xmlParserInputFlags flags )

Creates a new parser input to read from input callbacks and context.

url is used as base to resolve external entities and for error reporting.

ioRead is called to read new data into a provided buffer. It must return the number of bytes written into the buffer ot a negative xmlParserErrors code on failure.

ioClose is called after parsing has finished.

ioCtxt is an opaque pointer passed to the callbacks.

Since
2.14.0
Parameters
urlbase URL (optional)
ioReadread callback
ioCloseclose callback (optional)
ioCtxtIO context
flagsunused, pass 0
Returns
a new parser input or NULL if a memory allocation failed.

◆ xmlNewInputFromMemory()

xmlParserInput * xmlNewInputFromMemory ( const char * url,
const void * mem,
size_t size,
xmlParserInputFlags flags )

Creates a new parser input to read from a memory area.

url is used as base to resolve external entities and for error reporting.

If the XML_INPUT_BUF_STATIC flag is set, the memory area must stay unchanged until parsing has finished. This can avoid temporary copies.

If the XML_INPUT_BUF_ZERO_TERMINATED flag is set, the memory area must contain a zero byte after the buffer at position size. This can avoid temporary copies.

Since
2.14.0
Parameters
urlbase URL (optional)
mempointer to char array
sizesize of array
flagsoptimization hints
Returns
a new parser input or NULL if a memory allocation failed.

◆ xmlNewInputFromString()

xmlParserInput * xmlNewInputFromString ( const char * url,
const char * str,
xmlParserInputFlags flags )

Creates a new parser input to read from a zero-terminated string.

url is used as base to resolve external entities and for error reporting.

If the XML_INPUT_BUF_STATIC flag is set, the string must stay unchanged until parsing has finished. This can avoid temporary copies.

Since
2.14.0
Parameters
urlbase URL (optional)
strzero-terminated string
flagsoptimization hints
Returns
a new parser input or NULL if a memory allocation failed.

◆ xmlNewInputFromUrl()

xmlParserErrors xmlNewInputFromUrl ( const char * url,
xmlParserInputFlags flags,
xmlParserInput ** out )

Create a new input stream based on a file or a URL.

The flag XML_INPUT_UNZIP allows decompression.

The flag XML_INPUT_NETWORK allows network access.

The following resource loaders will be called if they were registered (in order of precedence):

Since
2.14.0
Parameters
urlthe filename to use as entity
flagsXML_INPUT flags
outpointer to new parser input
Returns
an xmlParserErrors code.

◆ xmlNewIOInputStream()

xmlParserInput * xmlNewIOInputStream ( xmlParserCtxt * ctxt,
xmlParserInputBuffer * buf,
xmlCharEncoding enc )

Create a new input stream structure encapsulating the input into a stream suitable for the parser.

Parameters
ctxtan XML parser context
bufan input buffer
encthe charset encoding if known
Returns
the new input stream or NULL

◆ xmlNewParserCtxt()

xmlParserCtxt * xmlNewParserCtxt ( void )

Allocate and initialize a new parser context.

Returns
the xmlParserCtxt or NULL

◆ xmlNewSAXParserCtxt()

xmlParserCtxt * xmlNewSAXParserCtxt ( const xmlSAXHandler * sax,
void * userData )

Allocate and initialize a new SAX parser context.

If userData is NULL, the parser context will be passed as user data.

Since
2.11.0

If you want support older versions, it's best to invoke xmlNewParserCtxt and set ctxt->sax with struct assignment.

Parameters
saxSAX handler
userDatauser data
Returns
the xmlParserCtxt or NULL if memory allocation failed.

◆ xmlParseBalancedChunkMemory()

int xmlParseBalancedChunkMemory ( xmlDoc * doc,
xmlSAXHandler * sax,
void * user_data,
int depth,
const xmlChar * string,
xmlNode ** lst )

Parse a well-balanced chunk of an XML document called by the parser The allowed sequence for the Well Balanced Chunk is the one defined by the content production in the XML grammar:

[43] content ::= (element | CharData | Reference | CDSect | PI |
                  Comment)*
Parameters
docthe document the chunk pertains to (must not be NULL)
saxthe SAX handler block (possibly NULL)
user_dataThe user data returned on SAX callbacks (possibly NULL)
depthUsed for loop detection, use 0
stringthe input string in UTF8 or ISO-Latin (zero terminated)
lstthe return value for the set of parsed nodes
Returns
0 if the chunk is well balanced, -1 in case of args problem and the parser error code otherwise

◆ xmlParseBalancedChunkMemoryRecover()

int xmlParseBalancedChunkMemoryRecover ( xmlDoc * doc,
xmlSAXHandler * sax,
void * user_data,
int depth,
const xmlChar * string,
xmlNode ** listOut,
int recover )

Parse a well-balanced chunk of an XML document.

The allowed sequence for the Well Balanced Chunk is the one defined by the content production in the XML grammar:

[43] content ::= (element | CharData | Reference | CDSect | PI |
                  Comment)*

In case recover is set to 1, the nodelist will not be empty even if the parsed chunk is not well balanced, assuming the parsing succeeded to some extent.

Parameters
docthe document the chunk pertains to (must not be NULL)
saxthe SAX handler block (possibly NULL)
user_dataThe user data returned on SAX callbacks (possibly NULL)
depthUsed for loop detection, use 0
stringthe input string in UTF8 or ISO-Latin (zero terminated)
listOutthe return value for the set of parsed nodes
recoverreturn nodes even if the data is broken (use 0)
Returns
0 if the chunk is well balanced, or thehe parser error code otherwise.

◆ xmlParseChunk()

int xmlParseChunk ( xmlParserCtxt * ctxt,
const char * chunk,
int size,
int terminate )

Parse a chunk of memory in push parser mode.

Assumes that the parser context was initialized with xmlCreatePushParserCtxt.

The last chunk, which will often be empty, must be marked with the terminate flag. With the default SAX callbacks, the resulting document will be available in ctxt->myDoc. This pointer will not be freed when calling xmlFreeParserCtxt and must be freed by the caller. If the document isn't well-formed, it will still be returned in ctxt->myDoc.

As an exception, xmlCtxtResetPush will free the document in ctxt->myDoc. So ctxt->myDoc should be set to NULL after extracting the document.

Since 2.14.0, xmlCtxtGetDocument can be used to retrieve the result document.

Parameters
ctxtan XML parser context
chunkchunk of memory
sizesize of chunk in bytes
terminatelast chunk indicator
Returns
an xmlParserErrors code (0 on success).

◆ xmlParseCtxtExternalEntity()

int xmlParseCtxtExternalEntity ( xmlParserCtxt * ctxt,
const xmlChar * URL,
const xmlChar * ID,
xmlNode ** listOut )

Parse an external general entity within an existing parsing context An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.

[78] extParsedEnt ::= TextDecl? content
Parameters
ctxtthe existing parsing context
URLthe URL for the entity to load
IDthe System ID for the entity to load
listOutthe return value for the set of parsed nodes
Returns
0 if the entity is well formed, -1 in case of args problem and the parser error code otherwise

◆ xmlParseDoc()

xmlDoc * xmlParseDoc ( const xmlChar * cur)

parse an XML in-memory document and build a tree.

Deprecated
Use xmlReadDoc.
Parameters
cura pointer to an array of xmlChar
Returns
the resulting document tree

◆ xmlParseDocument()

int xmlParseDocument ( xmlParserCtxt * ctxt)

Parse an XML document and invoke the SAX handlers.

This is useful if you're only interested in custom SAX callbacks. If you want a document tree, use xmlCtxtParseDocument.

Parameters
ctxtan XML parser context
Returns
0, -1 in case of error.

◆ xmlParseDTD()

xmlDtd * xmlParseDTD ( const xmlChar * publicId,
const xmlChar * systemId )

Load and parse an external subset.

Parameters
publicIdpublic identifier of the DTD (optional)
systemIdsystem identifier (URL) of the DTD
Returns
the resulting xmlDtd or NULL in case of error.

◆ xmlParseEntity()

xmlDoc * xmlParseEntity ( const char * filename)

parse an XML external entity out of context and build a tree.

[78] extParsedEnt ::= TextDecl? content

This correspond to a "Well Balanced" chunk

Parameters
filenamethe filename
Returns
the resulting document tree

◆ xmlParseExternalEntity()

int xmlParseExternalEntity ( xmlDoc * doc,
xmlSAXHandler * sax,
void * user_data,
int depth,
const xmlChar * URL,
const xmlChar * ID,
xmlNode ** list )

Parse an external general entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.

Deprecated
Use xmlParseCtxtExternalEntity.
[78] extParsedEnt ::= TextDecl? content
Parameters
docthe document the chunk pertains to
saxthe SAX handler block (possibly NULL)
user_dataThe user data returned on SAX callbacks (possibly NULL)
depthUsed for loop detection, use 0
URLthe URL for the entity to load
IDthe System ID for the entity to load
listthe return value for the set of parsed nodes
Returns
0 if the entity is well formed, -1 in case of args problem and the parser error code otherwise

◆ xmlParseExtParsedEnt()

int xmlParseExtParsedEnt ( xmlParserCtxt * ctxt)

parse a general parsed entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.

Deprecated
Internal function, don't use.
[78] extParsedEnt ::= TextDecl? content
Parameters
ctxtan XML parser context
Returns
0, -1 in case of error. the parser context is augmented as a result of the parsing.

◆ xmlParseFile()

xmlDoc * xmlParseFile ( const char * filename)

parse an XML file and build a tree.

Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Deprecated
Use xmlReadFile.
Parameters
filenamethe filename
Returns
the resulting document tree if the file was wellformed, NULL otherwise.

◆ xmlParseInNodeContext()

xmlParserErrors xmlParseInNodeContext ( xmlNode * node,
const char * data,
int datalen,
int options,
xmlNode ** listOut )

Parse a well-balanced chunk of an XML document within the context (DTD, namespaces, etc ...) of the given node.

The allowed sequence for the data is a Well Balanced Chunk defined by the content production in the XML grammar:

[43] content ::= (element | CharData | Reference | CDSect | PI |
                  Comment)*

This function assumes the encoding of node's document which is typically not what you want. A better alternative is xmlCtxtParseContent.

Parameters
nodethe context node
datathe input string
datalenthe input string length in bytes
optionsa combination of xmlParserOption
listOutthe return value for the set of parsed nodes
Returns
XML_ERR_OK if the chunk is well balanced, and the parser error code otherwise

◆ xmlParseMemory()

xmlDoc * xmlParseMemory ( const char * buffer,
int size )

parse an XML in-memory block and build a tree.

Deprecated
Use xmlReadMemory.
Parameters
bufferan pointer to a char array
sizethe size of the array
Returns
the resulting document tree

◆ xmlParserAddNodeInfo()

void xmlParserAddNodeInfo ( xmlParserCtxt * ctxt,
xmlParserNodeInfo * info )

Insert node info record into the sorted sequence.

Deprecated
Don't use.
Parameters
ctxtan XML parser context
infoa node info sequence pointer

◆ xmlParserFindNodeInfo()

const xmlParserNodeInfo * xmlParserFindNodeInfo ( xmlParserCtxt * ctx,
xmlNode * node )

Find the parser node info struct for a given node.

Deprecated
Don't use.
Parameters
ctxan XML parser context
nodean XML node within the tree
Returns
an xmlParserNodeInfo block pointer or NULL

◆ xmlParserFindNodeInfoIndex()

unsigned long xmlParserFindNodeInfoIndex ( xmlParserNodeInfoSeq * seq,
xmlNode * node )

Find the index that the info record for the given node is or should be at in a sorted sequence.

Deprecated
Don't use.
Parameters
seqa node info sequence pointer
nodean XML node pointer
Returns
a long indicating the position of the record

◆ xmlParserInputGrow()

int xmlParserInputGrow ( xmlParserInput * in,
int len )

This function increase the input for the parser.

It tries to preserve pointers to the input buffer, and keep already read data

Deprecated
Don't use.
Parameters
inan XML parser input
lenan indicative size for the lookahead
Returns
the amount of char read, or -1 in case of error, 0 indicate the end of this entity

◆ xmlParserInputRead()

int xmlParserInputRead ( xmlParserInput * in,
int len )
Deprecated
This function was internal and is deprecated.
Parameters
inan XML parser input
lenan indicative size for the lookahead
Returns
-1 as this is an error to use it.

◆ xmlPedanticParserDefault()

int xmlPedanticParserDefault ( int val)

Set and return the previous value for enabling pedantic warnings.

Deprecated
Use the modern options API with XML_PARSE_PEDANTIC.
Parameters
valint 0 or 1
Returns
the last value for 0 for no substitution, 1 for substitution.

◆ xmlReadDoc()

xmlDoc * xmlReadDoc ( const xmlChar * cur,
const char * URL,
const char * encoding,
int options )

Convenience function to parse an XML document from a zero-terminated string.

See xmlCtxtReadDoc for details.

Parameters
cura pointer to a zero terminated string
URLbase URL (optional)
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlReadFd()

xmlDoc * xmlReadFd ( int fd,
const char * URL,
const char * encoding,
int options )

Parse an XML from a file descriptor and build a tree.

See xmlCtxtReadFd for details.

NOTE that the file descriptor will not be closed when the context is freed or reset.

Parameters
fdan open file descriptor
URLbase URL (optional)
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlReadFile()

xmlDoc * xmlReadFile ( const char * filename,
const char * encoding,
int options )

Convenience function to parse an XML file from the filesystem, the network or a global user-define resource loader.

This function always enables the XML_PARSE_UNZIP option for backward compatibility. If a "-" filename is passed, it will read from stdin. Both of these features are potentially insecure and might be removed from later versions.

See xmlCtxtReadFile for details.

Parameters
filenamea file or URL
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlReadIO()

xmlDoc * xmlReadIO ( xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose,
void * ioctx,
const char * URL,
const char * encoding,
int options )

Parse an XML document from I/O functions and context and build a tree.

See xmlCtxtReadIO for details.

Parameters
ioreadan I/O read function
ioclosean I/O close function (optional)
ioctxan I/O handler
URLbase URL (optional)
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlReadMemory()

xmlDoc * xmlReadMemory ( const char * buffer,
int size,
const char * url,
const char * encoding,
int options )

Parse an XML in-memory document and build a tree.

The input buffer must not contain a terminating null byte.

See xmlCtxtReadMemory for details.

Parameters
buffera pointer to a char array
sizethe size of the array
urlbase URL (optional)
encodingthe document encoding (optional)
optionsa combination of xmlParserOption
Returns
the resulting document tree

◆ xmlRecoverDoc()

xmlDoc * xmlRecoverDoc ( const xmlChar * cur)

parse an XML in-memory document and build a tree.

In the case the document is not Well Formed, a attempt to build a tree is tried anyway

Deprecated
Use xmlReadDoc with XML_PARSE_RECOVER.
Parameters
cura pointer to an array of xmlChar
Returns
the resulting document tree or NULL in case of failure

◆ xmlRecoverFile()

xmlDoc * xmlRecoverFile ( const char * filename)

parse an XML file and build a tree.

Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. In the case the document is not Well Formed, it attempts to build a tree anyway

Deprecated
Use xmlReadFile with XML_PARSE_RECOVER.
Parameters
filenamethe filename
Returns
the resulting document tree or NULL in case of failure

◆ xmlRecoverMemory()

xmlDoc * xmlRecoverMemory ( const char * buffer,
int size )

parse an XML in-memory block and build a tree.

In the case the document is not Well Formed, an attempt to build a tree is tried anyway

Deprecated
Use xmlReadMemory with XML_PARSE_RECOVER.
Parameters
bufferan pointer to a char array
sizethe size of the array
Returns
the resulting document tree or NULL in case of error

◆ xmlSAXParseDoc()

xmlDoc * xmlSAXParseDoc ( xmlSAXHandler * sax,
const xmlChar * cur,
int recovery )

parse an XML in-memory document and build a tree.

It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.

Deprecated
Use xmlNewSAXParserCtxt and xmlCtxtReadDoc.
Parameters
saxthe SAX handler block
cura pointer to an array of xmlChar
recoverywork in recovery mode, i.e. tries to read no Well Formed documents
Returns
the resulting document tree

◆ xmlSAXParseDTD()

xmlDtd * xmlSAXParseDTD ( xmlSAXHandler * sax,
const xmlChar * publicId,
const xmlChar * systemId )

Load and parse an external subset.

Deprecated
Use xmlCtxtParseDtd.
Parameters
saxthe SAX handler block
publicIdpublic identifier of the DTD (optional)
systemIdsystem identifier (URL) of the DTD
Returns
the resulting xmlDtd or NULL in case of error.

◆ xmlSAXParseEntity()

xmlDoc * xmlSAXParseEntity ( xmlSAXHandler * sax,
const char * filename )

parse an XML external entity out of context and build a tree.

It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.

Deprecated
Don't use.
[78] extParsedEnt ::= TextDecl? content

This correspond to a "Well Balanced" chunk

Parameters
saxthe SAX handler block
filenamethe filename
Returns
the resulting document tree

◆ xmlSAXParseFile()

xmlDoc * xmlSAXParseFile ( xmlSAXHandler * sax,
const char * filename,
int recovery )

parse an XML file and build a tree.

Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.

Deprecated
Use xmlNewSAXParserCtxt and xmlCtxtReadFile.
Parameters
saxthe SAX handler block
filenamethe filename
recoverywork in recovery mode, i.e. tries to read no Well Formed documents
Returns
the resulting document tree

◆ xmlSAXParseFileWithData()

xmlDoc * xmlSAXParseFileWithData ( xmlSAXHandler * sax,
const char * filename,
int recovery,
void * data )

parse an XML file and build a tree.

Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. It use the given SAX function block to handle the parsing callback. If sax is NULL, fallback to the default DOM tree building routines.

Deprecated
Use xmlNewSAXParserCtxt and xmlCtxtReadFile.

User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml

Parameters
saxthe SAX handler block
filenamethe filename
recoverywork in recovery mode, i.e. tries to read no Well Formed documents
datathe userdata
Returns
the resulting document tree

◆ xmlSAXParseMemory()

xmlDoc * xmlSAXParseMemory ( xmlSAXHandler * sax,
const char * buffer,
int size,
int recovery )

parse an XML in-memory block and use the given SAX function block to handle the parsing callback.

If sax is NULL, fallback to the default DOM tree building routines.

Deprecated
Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.
Parameters
saxthe SAX handler block
bufferan pointer to a char array
sizethe size of the array
recoverywork in recovery mode, i.e. tries to read not Well Formed documents
Returns
the resulting document tree

◆ xmlSAXParseMemoryWithData()

xmlDoc * xmlSAXParseMemoryWithData ( xmlSAXHandler * sax,
const char * buffer,
int size,
int recovery,
void * data )

parse an XML in-memory block and use the given SAX function block to handle the parsing callback.

If sax is NULL, fallback to the default DOM tree building routines.

Deprecated
Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.

User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml

Parameters
saxthe SAX handler block
bufferan pointer to a char array
sizethe size of the array
recoverywork in recovery mode, i.e. tries to read no Well Formed documents
datathe userdata
Returns
the resulting document tree

◆ xmlSAXUserParseFile()

int xmlSAXUserParseFile ( xmlSAXHandler * sax,
void * user_data,
const char * filename )

parse an XML file and call the given SAX handler routines.

Automatic support for ZLIB/Compress compressed document is provided

Deprecated
Use xmlNewSAXParserCtxt and xmlCtxtReadFile.
Parameters
saxa SAX handler
user_dataThe user data returned on SAX callbacks
filenamea file name
Returns
0 in case of success or a error number otherwise

◆ xmlSAXUserParseMemory()

int xmlSAXUserParseMemory ( xmlSAXHandler * sax,
void * user_data,
const char * buffer,
int size )

parse an XML in-memory buffer and call the given SAX handler routines.

Deprecated
Use xmlNewSAXParserCtxt and xmlCtxtReadMemory.
Parameters
saxa SAX handler
user_dataThe user data returned on SAX callbacks
bufferan in-memory XML document input
sizethe length of the XML document in bytes
Returns
0 in case of success or a error number otherwise

◆ xmlSetExternalEntityLoader()

void xmlSetExternalEntityLoader ( xmlExternalEntityLoader f)

Changes the default external entity resolver function for the application.

Deprecated
This is a global setting and not thread-safe. Use xmlCtxtSetResourceLoader or similar functions.
Parameters
fthe new entity resolver function

◆ xmlSetupParserForBuffer()

void xmlSetupParserForBuffer ( xmlParserCtxt * ctxt,
const xmlChar * buffer,
const char * filename )

Setup the parser context to parse a new buffer; Clears any prior contents from the parser context.

The buffer parameter must not be NULL, but the filename parameter can be

Deprecated
Don't use.
Parameters
ctxtan XML parser context
buffera xmlChar * buffer
filenamea file name

◆ xmlStopParser()

void xmlStopParser ( xmlParserCtxt * ctxt)

Blocks further parser processing.

Parameters
ctxtan XML parser context

◆ xmlSubstituteEntitiesDefault()

int xmlSubstituteEntitiesDefault ( int val)

Set and return the previous value for default entity support.

Deprecated
Use the modern options API with XML_PARSE_NOENT.
Parameters
valint 0 or 1
Returns
the last value for 0 for no substitution, 1 for substitution.

◆ xmlThrDefDoValidityCheckingDefaultValue()

int xmlThrDefDoValidityCheckingDefaultValue ( int v)

Set per-thread default value.

Deprecated
Use xmlParserOption XML_PARSE_DTDVALID.
Parameters
vnew value
Returns
the old value

◆ xmlThrDefGetWarningsDefaultValue()

int xmlThrDefGetWarningsDefaultValue ( int v)

Set per-thread default value.

Deprecated
Use xmlParserOption XML_PARSE_NOWARNING.
Parameters
vnew value
Returns
the old value

◆ xmlThrDefKeepBlanksDefaultValue()

int xmlThrDefKeepBlanksDefaultValue ( int v)

Set per-thread default value.

Deprecated
Whitespace is kept by default. Use xmlParserOption XML_PARSE_NOBLANKS to remove whitespace.
Parameters
vnew value
Returns
the old value

◆ xmlThrDefLineNumbersDefaultValue()

int xmlThrDefLineNumbersDefaultValue ( int v)

Set per-thread default value.

Deprecated
Has no effect.
Parameters
vunused
Returns
1

◆ xmlThrDefLoadExtDtdDefaultValue()

int xmlThrDefLoadExtDtdDefaultValue ( int v)

Set per-thread default value.

Deprecated
Use xmlParserOption XML_PARSE_DTDLOAD.
Parameters
vnew value
Returns
the old value

◆ xmlThrDefPedanticParserDefaultValue()

int xmlThrDefPedanticParserDefaultValue ( int v)

Set per-thread default value.

Deprecated
Use xmlParserOption XML_PARSE_PEDANTIC.
Parameters
vnew value
Returns
the old value

◆ xmlThrDefSubstituteEntitiesDefaultValue()

int xmlThrDefSubstituteEntitiesDefaultValue ( int v)

Set per-thread default value.

Deprecated
Use xmlParserOption XML_PARSE_NOENT.
Parameters
vnew value
Returns
the old value