libxml2
|
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. | |
xmlDoc * | xmlParseDoc (const xmlChar *cur) |
parse an XML in-memory document and build a tree. | |
xmlDoc * | xmlParseFile (const char *filename) |
parse an XML file and build a tree. | |
xmlDoc * | xmlParseMemory (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. | |
xmlDoc * | xmlRecoverDoc (const xmlChar *cur) |
parse an XML in-memory document and build a tree. | |
xmlDoc * | xmlRecoverMemory (const char *buffer, int size) |
parse an XML in-memory block and build a tree. | |
xmlDoc * | xmlRecoverFile (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. | |
xmlDoc * | xmlSAXParseDoc (xmlSAXHandler *sax, const xmlChar *cur, int recovery) |
parse an XML in-memory document and build a tree. | |
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. | |
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. | |
xmlDoc * | xmlSAXParseFile (xmlSAXHandler *sax, const char *filename, int recovery) |
parse an XML file and build a tree. | |
xmlDoc * | xmlSAXParseFileWithData (xmlSAXHandler *sax, const char *filename, int recovery, void *data) |
parse an XML file and build a tree. | |
xmlDoc * | xmlSAXParseEntity (xmlSAXHandler *sax, const char *filename) |
parse an XML external entity out of context and build a tree. | |
xmlDoc * | xmlParseEntity (const char *filename) |
parse an XML external entity out of context and build a tree. | |
xmlDtd * | xmlCtxtParseDtd (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. | |
xmlDtd * | xmlSAXParseDTD (xmlSAXHandler *sax, const xmlChar *publicId, const xmlChar *systemId) |
Load and parse an external subset. | |
xmlDtd * | xmlParseDTD (const xmlChar *publicId, const xmlChar *systemId) |
Load and parse an external subset. | |
xmlDtd * | xmlIOParseDTD (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. | |
xmlParserCtxt * | xmlNewParserCtxt (void) |
Allocate and initialize a new parser context. | |
xmlParserCtxt * | xmlNewSAXParserCtxt (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. | |
xmlParserCtxt * | xmlCreateDocParserCtxt (const xmlChar *cur) |
Creates a parser context for an XML in-memory document. | |
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. | |
int | xmlParseChunk (xmlParserCtxt *ctxt, const char *chunk, int size, int terminate) |
Parse a chunk of memory in push parser mode. | |
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. | |
xmlParserInput * | xmlNewIOInputStream (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. | |
xmlParserInput * | xmlLoadExternalEntity (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. | |
xmlSAXHandler * | xmlCtxtGetSaxHandler (xmlParserCtxt *ctxt) |
int | xmlCtxtSetSaxHandler (xmlParserCtxt *ctxt, const xmlSAXHandler *sax) |
Set the SAX handler struct to a copy of sax. | |
xmlDoc * | xmlCtxtGetDocument (xmlParserCtxt *ctxt) |
int | xmlCtxtIsHtml (xmlParserCtxt *ctxt) |
int | xmlCtxtIsStopped (xmlParserCtxt *ctxt) |
Check whether the parser is stopped. | |
xmlValidCtxt * | xmlCtxtGetValidCtxt (xmlParserCtxt *ctxt) |
const xmlChar * | xmlCtxtGetVersion (xmlParserCtxt *ctxt) |
const xmlChar * | xmlCtxtGetDeclaredEncoding (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. | |
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. | |
xmlDoc * | xmlReadFile (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. | |
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. | |
xmlDoc * | xmlReadFd (int fd, const char *URL, const char *encoding, int options) |
Parse an XML from a file descriptor and build a tree. | |
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. | |
xmlDoc * | xmlCtxtParseDocument (xmlParserCtxt *ctxt, xmlParserInput *input) |
Parse an XML document and return the resulting document tree. | |
xmlNode * | xmlCtxtParseContent (xmlParserCtxt *ctxt, xmlParserInput *input, xmlNode *node, int hasTextDecl) |
Parse a well-balanced chunk of XML matching the 'content' production. | |
xmlDoc * | xmlCtxtReadDoc (xmlParserCtxt *ctxt, const xmlChar *cur, const char *URL, const char *encoding, int options) |
Parse an XML in-memory document and build a tree. | |
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. | |
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. | |
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. | |
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. | |
xmlParserErrors | xmlNewInputFromUrl (const char *url, xmlParserInputFlags flags, xmlParserInput **out) |
Create a new input stream based on a file or a URL. | |
xmlParserInput * | xmlNewInputFromMemory (const char *url, const void *mem, size_t size, xmlParserInputFlags flags) |
Creates a new parser input to read from a memory area. | |
xmlParserInput * | xmlNewInputFromString (const char *url, const char *str, xmlParserInputFlags flags) |
Creates a new parser input to read from a zero-terminated string. | |
xmlParserInput * | xmlNewInputFromFd (const char *url, int fd, xmlParserInputFlags flags) |
Creates a new parser input to read from a file descriptor. | |
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. | |
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. |
Validating XML 1.0 parser.
Interfaces, constants and types related to the XML parser.
#define xmlDoValidityCheckingDefaultValue (*__xmlDoValidityCheckingDefaultValue()) |
Thread-local setting to enable validation.
Defaults to 0.
#define xmlGetWarningsDefaultValue (*__xmlGetWarningsDefaultValue()) |
Thread-local setting to disable warnings.
Defaults to 1.
#define xmlIndentTreeOutput (*__xmlIndentTreeOutput()) |
Thread-local setting to disable indenting when formatting output.
Defaults to 1.
#define xmlKeepBlanksDefaultValue (*__xmlKeepBlanksDefaultValue()) |
Thread-local setting to ignore some whitespace.
Defaults to 1.
#define xmlLineNumbersDefaultValue (*__xmlLineNumbersDefaultValue()) |
Thread-local setting to store line numbers.
Defaults to 0, but is always enabled after setting parser options.
#define xmlLoadExtDtdDefaultValue (*__xmlLoadExtDtdDefaultValue()) |
Thread-local setting to enable loading of external DTDs.
Defaults to 0.
#define xmlPedanticParserDefaultValue (*__xmlPedanticParserDefaultValue()) |
Thread-local setting to enable pedantic warnings.
Defaults to 0.
#define xmlSaveNoEmptyTags (*__xmlSaveNoEmptyTags()) |
Thread-local setting to disable empty tags when serializing.
Defaults to 0.
#define xmlSubstituteEntitiesDefaultValue (*__xmlSubstituteEntitiesDefaultValue()) |
Thread-local setting to enable entity substitution.
Defaults to 0.
#define xmlTreeIndentString (*__xmlTreeIndentString()) |
Thread-local setting to change the indent string.
Defaults to two spaces.
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.
ctx | the user data (XML parser context) |
elem | the name of the element |
fullname | the attribute name |
type | the attribute type |
def | the type of default value |
defaultValue | the attribute default value |
tree | the tree of enumerated value set |
Callback for attributes.
ctx | the user data (XML parser context) |
name | The attribute name, including namespace prefix |
value | The attribute value |
typedef void(* cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len) |
SAX callback for CDATA sections.
ctx | the user data (XML parser context) |
value | The pcdata content |
len | the block length |
typedef void(* charactersSAXFunc) (void *ctx, const xmlChar *ch, int len) |
typedef void(* commentSAXFunc) (void *ctx, const xmlChar *value) |
SAX callback for comments.
ctx | the user data (XML parser context) |
value | the comment content |
typedef void(* elementDeclSAXFunc) (void *ctx, const xmlChar *name, int type, xmlElementContent *content) |
SAX callback for element declarations.
ctx | the user data (XML parser context) |
name | the element name |
type | the element type |
content | the element value tree |
typedef void(* endDocumentSAXFunc) (void *ctx) |
SAX callback for end of document.
ctx | the user data (XML parser context) |
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.
ctx | the user data (XML parser context) |
localname | the local name of the element |
prefix | the element namespace prefix if available |
URI | the element namespace name if available |
typedef void(* endElementSAXFunc) (void *ctx, const xmlChar *name) |
SAX callback for end tags.
ctx | the user data (XML parser context) |
name | The element name |
typedef void(* entityDeclSAXFunc) (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) |
SAX callback for entity declarations.
ctx | the user data (XML parser context) |
name | the entity name |
type | the entity type |
publicId | The public ID of the entity |
systemId | The system ID of the entity |
content | the entity value (without processing). |
typedef void(* errorSAXFunc) (void *ctx, const char *msg,...) |
SAX callback for error messages.
ctx | an XML parser context |
msg | the message to display/transmit |
... | extra parameters for the message display |
typedef void(* externalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) |
SAX callback for the external subset.
ctx | the user data (XML parser context) |
name | the root element name |
publicId | the public identifier |
systemId | the system identifier (e.g. filename or URL) |
typedef void(* fatalErrorSAXFunc) (void *ctx, const char *msg,...) |
SAX callback for fatal error messages.
ctx | an XML parser context |
msg | the message to display/transmit |
... | extra parameters for the message display |
SAX callback to look up a general entity by name.
ctx | the user data (XML parser context) |
name | The entity name |
SAX callback to look up a parameter entity by name.
ctx | the user data (XML parser context) |
name | The entity name |
typedef int(* hasExternalSubsetSAXFunc) (void *ctx) |
SAX callback to get external subset status.
ctx | the user data (XML parser context) |
typedef int(* hasInternalSubsetSAXFunc) (void *ctx) |
SAX callback to get internal subset status.
ctx | the user data (XML parser context) |
typedef void(* ignorableWhitespaceSAXFunc) (void *ctx, const xmlChar *ch, int len) |
typedef void(* internalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) |
SAX callback for the internal subset.
ctx | the user data (XML parser context) |
name | the root element name |
publicId | the public identifier |
systemId | the system identifier (e.g. filename or URL) |
typedef int(* isStandaloneSAXFunc) (void *ctx) |
SAX callback to get standalone status.
ctx | the user data (XML parser context) |
typedef void(* notationDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) |
SAX callback for notation declarations.
ctx | the user data (XML parser context) |
name | The name of the notation |
publicId | The public ID of the notation |
systemId | The system ID of the notation |
typedef void(* processingInstructionSAXFunc) (void *ctx, const xmlChar *target, const xmlChar *data) |
SAX callback for processing instructions.
ctx | the user data (XML parser context) |
target | the target name |
data | the PI data's |
typedef void(* referenceSAXFunc) (void *ctx, const xmlChar *name) |
SAX callback for entity references.
ctx | the user data (XML parser context) |
name | The entity name |
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.
ctx | the user data (XML parser context) |
publicId | The public identifier of the entity |
systemId | The system identifier of the entity (URL) |
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.
ctx | the user data (XML parser context) |
loc | A SAX Locator |
typedef void(* startDocumentSAXFunc) (void *ctx) |
SAX callback for start of document.
ctx | the user data (XML parser context) |
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.
ctx | the user data (XML parser context) |
localname | the local name of the element |
prefix | the element namespace prefix if available |
URI | the element namespace name if available |
nb_namespaces | number of namespace definitions on that node |
namespaces | pointer to the array of prefix/URI pairs namespace definitions |
nb_attributes | the number of attributes on that node |
nb_defaulted | the number of defaulted attributes. The defaulted ones are at the end of the array |
attributes | pointer to the array of (localname/prefix/URI/value/end) attribute values. |
SAX callback for start tags.
ctx | the user data (XML parser context) |
name | The element name, including namespace prefix |
atts | An array of name/value attributes pairs, NULL terminated |
typedef void(* unparsedEntityDeclSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName) |
SAX callback for unparsed entity declarations.
ctx | the user data (XML parser context) |
name | The name of the entity |
publicId | The public ID of the entity |
systemId | The system ID of the entity |
notationName | the name of the notation |
typedef void(* warningSAXFunc) (void *ctx, const char *msg,...) |
SAX callback for warning messages.
ctx | an XML parser context |
msg | the message to display/transmit |
... | extra parameters for the message display |
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.
URL | The URL or system ID of the resource requested |
publicId | The public ID of the resource requested (optional) |
context | the XML parser context |
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.
ctxt | parser context |
url | URL or system ID to load |
publicId | publid ID from DTD (optional) |
type | resource type |
flags | flags |
out | result pointer |
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 |
|
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 |
|
XML_WITH_HTTP |
|
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 |
|
XML_WITH_REGEXP | Regular expressions. |
XML_WITH_AUTOMATA |
|
XML_WITH_EXPR |
|
XML_WITH_SCHEMAS | XML Schemas. |
XML_WITH_SCHEMATRON | Schematron. |
XML_WITH_MODULES | Loadable modules. |
XML_WITH_DEBUG | Debugging API. |
XML_WITH_DEBUG_MEM |
|
XML_WITH_DEBUG_RUN |
|
XML_WITH_ZLIB | GZIP compression. |
XML_WITH_ICU | ICU. |
XML_WITH_LZMA | LZMA compression. |
XML_WITH_RELAXNG | RELAXNG, since 2.14. |
enum xmlParserInputFlags |
Flags for parser input.
enum 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.
|
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.
|
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.
|
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.
|
XML_PARSE_UNZIP | Enable input decompression. Setting this option is discouraged to avoid zip bombs.
|
XML_PARSE_NO_SYS_CATALOG | Disables the global system XML catalog.
|
XML_PARSE_CATALOG_PI | Enable XML catalog processing instructions.
|
XML_PARSE_SKIP_IDS | Force the parser to ignore IDs.
|
enum xmlParserStatus |
enum xmlResourceType |
Resource type for resource loaders.
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.
ctxt | an XML parser context |
void xmlCleanupGlobals | ( | void | ) |
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.
void xmlClearNodeInfoSeq | ( | xmlParserNodeInfoSeq * | seq | ) |
Clear (release memory and reinitialize) node info sequence.
seq | a node info sequence pointer |
void xmlClearParserCtxt | ( | xmlParserCtxt * | ctxt | ) |
xmlParserCtxt * xmlCreateDocParserCtxt | ( | const xmlChar * | str | ) |
Creates a parser context for an XML in-memory document.
str | a pointer to an array of xmlChar |
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.
sax | a SAX handler (optional) |
user_data | user data for SAX callbacks (optional) |
ioread | an I/O read function |
ioclose | an I/O close function (optional) |
ioctx | an I/O handler |
enc | the charset encoding if known (deprecated) |
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.
sax | a SAX handler (optional) |
user_data | user data for SAX callbacks (optional) |
chunk | initial chunk (optional, deprecated) |
size | size of initial chunk in bytes |
filename | file name or URI (optional) |
void * xmlCtxtGetCatalogs | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
const xmlChar * xmlCtxtGetDeclaredEncoding | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
xmlDict * xmlCtxtGetDict | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
xmlDoc * xmlCtxtGetDocument | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
int xmlCtxtGetOptions | ( | xmlParserCtxt * | ctxt | ) |
Get the current options of the parser context.
ctxt | an XML parser context |
void * xmlCtxtGetPrivate | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
xmlSAXHandler * xmlCtxtGetSaxHandler | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
int xmlCtxtGetStandalone | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
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.
ctxt | an XML parser context |
xmlValidCtxt * xmlCtxtGetValidCtxt | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
const xmlChar * xmlCtxtGetVersion | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
int xmlCtxtIsHtml | ( | xmlParserCtxt * | ctxt | ) |
ctxt | parser context |
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.
ctxt | parser context |
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.
ctxt | parser context |
input | parser input |
node | target node or document |
hasTextDecl | whether to parse text declaration |
xmlDoc * xmlCtxtParseDocument | ( | xmlParserCtxt * | ctxt, |
xmlParserInput * | input ) |
Parse an XML document and return the resulting document tree.
Takes ownership of the input object.
ctxt | an XML parser context |
input | parser input |
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.
ctxt | a parser context |
input | a parser input |
publicId | public ID of the DTD (optional) |
systemId | system ID of the DTD (optional) |
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.
ctxt | an XML parser context |
str | a pointer to a zero terminated string |
URL | base URL (optional) |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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.
ctxt | an XML parser context |
fd | an open file descriptor |
URL | base URL (optional) |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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.
ctxt | an XML parser context |
filename | a file or URL |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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.
ctxt | an XML parser context |
ioread | an I/O read function |
ioclose | an I/O close function |
ioctx | an I/O handler |
URL | the base URL to use for the document |
encoding | the document encoding, or NULL |
options | a combination of xmlParserOption |
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.
ctxt | an XML parser context |
buffer | a pointer to a char array |
size | the size of the array |
URL | base URL (optional) |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
void xmlCtxtReset | ( | xmlParserCtxt * | ctxt | ) |
Reset a parser context.
ctxt | an XML parser context |
int xmlCtxtResetPush | ( | xmlParserCtxt * | ctxt, |
const char * | chunk, | ||
int | size, | ||
const char * | filename, | ||
const char * | encoding ) |
Reset a push parser context.
ctxt | an XML parser context |
chunk | a pointer to an array of chars |
size | number of chars in the array |
filename | an optional file name or URI |
encoding | the document encoding, or NULL |
void xmlCtxtSetCatalogs | ( | xmlParserCtxt * | ctxt, |
void * | catalogs ) |
Set the local catalogs.
ctxt | parser context |
catalogs | catalogs pointer |
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.
ctxt | parser context |
impl | callback |
vctxt | user data |
void xmlCtxtSetDict | ( | xmlParserCtxt * | ctxt, |
xmlDict * | dict ) |
Set the dictionary.
This should only be done immediately after creating a parser context.
ctxt | parser context |
dict | dictionary |
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):
ctxt | an XML parser context |
handler | error handler |
data | data for error handler |
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.
ctxt | an XML parser context |
maxAmpl | maximum amplification factor |
int xmlCtxtSetOptions | ( | xmlParserCtxt * | ctxt, |
int | options ) |
Applies the options to the parser context.
Unset options are cleared.
With older versions, you can use xmlCtxtUseOptions.
ctxt | an XML parser context |
options | a bitmask of xmlParserOption values |
void xmlCtxtSetPrivate | ( | xmlParserCtxt * | ctxt, |
void * | priv ) |
Set the private application data.
ctxt | parser context |
priv | private application data |
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.
ctxt | parser context |
loader | callback |
vctxt | user data (optional) |
int xmlCtxtSetSaxHandler | ( | xmlParserCtxt * | ctxt, |
const xmlSAXHandler * | sax ) |
Set the SAX handler struct to a copy of sax.
ctxt | parser context |
sax | SAX handler |
int xmlCtxtUseOptions | ( | xmlParserCtxt * | ctxt, |
int | options ) |
Applies the options to the parser context.
The following options are never cleared and can only be enabled:
ctxt | an XML parser context |
options | a combination of xmlParserOption |
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.
ctxt | a parser context |
doc | a document instance |
int xmlCtxtValidateDtd | ( | xmlParserCtxt * | ctxt, |
xmlDoc * | doc, | ||
xmlDtd * | dtd ) |
Validate a document against a DTD.
Like xmlValidateDtd but uses the parser context's error handler.
ctxt | a parser context |
doc | a document instance |
dtd | a dtd instance |
void xmlFreeParserCtxt | ( | xmlParserCtxt * | ctxt | ) |
Free all the memory used by a parser context.
However the parsed document in ctxt->myDoc is not freed.
ctxt | an XML parser context |
xmlExternalEntityLoader xmlGetExternalEntityLoader | ( | void | ) |
Get the default external entity resolver function for the application.
int xmlHasFeature | ( | xmlFeature | feature | ) |
Examines if the library has been compiled with a given feature.
feature | the feature to be examined |
void xmlInitGlobals | ( | void | ) |
void xmlInitNodeInfoSeq | ( | xmlParserNodeInfoSeq * | seq | ) |
Initialize (set to initial state) node info sequence.
seq | a node info sequence pointer |
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.
int xmlInitParserCtxt | ( | xmlParserCtxt * | ctxt | ) |
Initialize a parser context.
ctxt | an XML parser context |
xmlParserErrors xmlInputSetEncodingHandler | ( | xmlParserInput * | input, |
xmlCharEncodingHandler * | handler ) |
Use encoding handler to decode input data.
Closes the handler on error.
input | the input stream |
handler | the encoding handler |
xmlDtd * xmlIOParseDTD | ( | xmlSAXHandler * | sax, |
xmlParserInputBuffer * | input, | ||
xmlCharEncoding | enc ) |
Load and parse a DTD.
sax | the SAX handler block or NULL |
input | an Input Buffer |
enc | the charset encoding if known |
int xmlKeepBlanksDefault | ( | int | val | ) |
Set and return the previous value for default blanks text nodes support.
val | int 0 or 1 |
int xmlLineNumbersDefault | ( | int | val | ) |
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):
URL | the URL or system ID for the entity to load |
publicId | the public ID for the entity to load (optional) |
ctxt | the context in which the entity is called or NULL |
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.
url | base URL (optional) |
fd | file descriptor |
flags | input flags |
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.
url | base URL (optional) |
ioRead | read callback |
ioClose | close callback (optional) |
ioCtxt | IO context |
flags | unused, pass 0 |
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.
url | base URL (optional) |
mem | pointer to char array |
size | size of array |
flags | optimization hints |
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.
url | base URL (optional) |
str | zero-terminated string |
flags | optimization hints |
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):
url | the filename to use as entity |
flags | XML_INPUT flags |
out | pointer to new parser input |
xmlParserInput * xmlNewIOInputStream | ( | xmlParserCtxt * | ctxt, |
xmlParserInputBuffer * | buf, | ||
xmlCharEncoding | enc ) |
Create a new input stream structure encapsulating the input into a stream suitable for the parser.
ctxt | an XML parser context |
buf | an input buffer |
enc | the charset encoding if known |
xmlParserCtxt * xmlNewParserCtxt | ( | void | ) |
Allocate and initialize a new parser context.
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.
If you want support older versions, it's best to invoke xmlNewParserCtxt and set ctxt->sax with struct assignment.
sax | SAX handler |
userData | user data |
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)*
doc | the document the chunk pertains to (must not be NULL) |
sax | the SAX handler block (possibly NULL) |
user_data | The user data returned on SAX callbacks (possibly NULL) |
depth | Used for loop detection, use 0 |
string | the input string in UTF8 or ISO-Latin (zero terminated) |
lst | the return value for the set of parsed nodes |
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.
doc | the document the chunk pertains to (must not be NULL) |
sax | the SAX handler block (possibly NULL) |
user_data | The user data returned on SAX callbacks (possibly NULL) |
depth | Used for loop detection, use 0 |
string | the input string in UTF8 or ISO-Latin (zero terminated) |
listOut | the return value for the set of parsed nodes |
recover | return nodes even if the data is broken (use 0) |
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.
ctxt | an XML parser context |
chunk | chunk of memory |
size | size of chunk in bytes |
terminate | last chunk indicator |
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
ctxt | the existing parsing context |
URL | the URL for the entity to load |
ID | the System ID for the entity to load |
listOut | the return value for the set of parsed nodes |
parse an XML in-memory document and build a tree.
cur | a pointer to an array of xmlChar |
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.
ctxt | an XML parser context |
Load and parse an external subset.
publicId | public identifier of the DTD (optional) |
systemId | system identifier (URL) of the DTD |
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
filename | the filename |
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.
[78] extParsedEnt ::= TextDecl? content
doc | the document the chunk pertains to |
sax | the SAX handler block (possibly NULL) |
user_data | The user data returned on SAX callbacks (possibly NULL) |
depth | Used for loop detection, use 0 |
URL | the URL for the entity to load |
ID | the System ID for the entity to load |
list | the return value for the set of parsed nodes |
int xmlParseExtParsedEnt | ( | xmlParserCtxt * | ctxt | ) |
parse a general parsed entity An external general parsed entity is well-formed if it matches the production labeled extParsedEnt.
[78] extParsedEnt ::= TextDecl? content
ctxt | an XML parser context |
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.
filename | the filename |
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.
node | the context node |
data | the input string |
datalen | the input string length in bytes |
options | a combination of xmlParserOption |
listOut | the return value for the set of parsed nodes |
xmlDoc * xmlParseMemory | ( | const char * | buffer, |
int | size ) |
parse an XML in-memory block and build a tree.
buffer | an pointer to a char array |
size | the size of the array |
void xmlParserAddNodeInfo | ( | xmlParserCtxt * | ctxt, |
xmlParserNodeInfo * | info ) |
Insert node info record into the sorted sequence.
ctxt | an XML parser context |
info | a node info sequence pointer |
const xmlParserNodeInfo * xmlParserFindNodeInfo | ( | xmlParserCtxt * | ctx, |
xmlNode * | node ) |
Find the parser node info struct for a given node.
ctx | an XML parser context |
node | an XML node within the tree |
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.
seq | a node info sequence pointer |
node | an XML node pointer |
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
in | an XML parser input |
len | an indicative size for the lookahead |
int xmlParserInputRead | ( | xmlParserInput * | in, |
int | len ) |
in | an XML parser input |
len | an indicative size for the lookahead |
int xmlPedanticParserDefault | ( | int | val | ) |
Set and return the previous value for enabling pedantic warnings.
val | int 0 or 1 |
Convenience function to parse an XML document from a zero-terminated string.
See xmlCtxtReadDoc for details.
cur | a pointer to a zero terminated string |
URL | base URL (optional) |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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.
fd | an open file descriptor |
URL | base URL (optional) |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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.
filename | a file or URL |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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.
ioread | an I/O read function |
ioclose | an I/O close function (optional) |
ioctx | an I/O handler |
URL | base URL (optional) |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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.
buffer | a pointer to a char array |
size | the size of the array |
url | base URL (optional) |
encoding | the document encoding (optional) |
options | a combination of xmlParserOption |
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
cur | a pointer to an array of xmlChar |
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
filename | the filename |
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
buffer | an pointer to a char array |
size | the size of the array |
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.
sax | the SAX handler block |
cur | a pointer to an array of xmlChar |
recovery | work in recovery mode, i.e. tries to read no Well Formed documents |
xmlDtd * xmlSAXParseDTD | ( | xmlSAXHandler * | sax, |
const xmlChar * | publicId, | ||
const xmlChar * | systemId ) |
Load and parse an external subset.
sax | the SAX handler block |
publicId | public identifier of the DTD (optional) |
systemId | system identifier (URL) of the DTD |
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.
[78] extParsedEnt ::= TextDecl? content
This correspond to a "Well Balanced" chunk
sax | the SAX handler block |
filename | the filename |
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.
sax | the SAX handler block |
filename | the filename |
recovery | work in recovery mode, i.e. tries to read no Well Formed documents |
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.
User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml
sax | the SAX handler block |
filename | the filename |
recovery | work in recovery mode, i.e. tries to read no Well Formed documents |
data | the userdata |
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.
sax | the SAX handler block |
buffer | an pointer to a char array |
size | the size of the array |
recovery | work in recovery mode, i.e. tries to read not Well Formed documents |
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.
User data (void *) is stored within the parser context in the context's _private member, so it is available nearly everywhere in libxml
sax | the SAX handler block |
buffer | an pointer to a char array |
size | the size of the array |
recovery | work in recovery mode, i.e. tries to read no Well Formed documents |
data | the userdata |
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
sax | a SAX handler |
user_data | The user data returned on SAX callbacks |
filename | a file name |
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.
sax | a SAX handler |
user_data | The user data returned on SAX callbacks |
buffer | an in-memory XML document input |
size | the length of the XML document in bytes |
void xmlSetExternalEntityLoader | ( | xmlExternalEntityLoader | f | ) |
Changes the default external entity resolver function for the application.
f | the new entity resolver function |
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
ctxt | an XML parser context |
buffer | a xmlChar * buffer |
filename | a file name |
void xmlStopParser | ( | xmlParserCtxt * | ctxt | ) |
Blocks further parser processing.
ctxt | an XML parser context |
int xmlSubstituteEntitiesDefault | ( | int | val | ) |
Set and return the previous value for default entity support.
val | int 0 or 1 |
int xmlThrDefDoValidityCheckingDefaultValue | ( | int | v | ) |
Set per-thread default value.
v | new value |
int xmlThrDefGetWarningsDefaultValue | ( | int | v | ) |
Set per-thread default value.
v | new value |
int xmlThrDefKeepBlanksDefaultValue | ( | int | v | ) |
Set per-thread default value.
v | new value |
int xmlThrDefLineNumbersDefaultValue | ( | int | v | ) |
int xmlThrDefLoadExtDtdDefaultValue | ( | int | v | ) |
Set per-thread default value.
v | new value |
int xmlThrDefPedanticParserDefaultValue | ( | int | v | ) |
Set per-thread default value.
v | new value |
int xmlThrDefSubstituteEntitiesDefaultValue | ( | int | v | ) |
Set per-thread default value.
v | new value |