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

Document tree API. More...

Data Structures

struct  _xmlBuffer
 A buffer structure, this old construct is limited to 2GB and is being deprecated, use API with xmlBuf instead. More...
struct  _xmlNotation
 A DTD Notation definition. More...
struct  _xmlEnumeration
 List structure used when there is an enumeration in DTDs. More...
struct  _xmlAttribute
 An Attribute declaration in a DTD. More...
struct  _xmlElementContent
 An XML Element content as stored after parsing an element definition in a DTD. More...
struct  _xmlElement
 An XML Element declaration from a DTD. More...
struct  _xmlNs
 An XML namespace. More...
struct  _xmlDtd
 An XML DTD, as defined by <!DOCTYPE ... There is actually one for the internal subset and for the external subset. More...
struct  _xmlAttr
 An attribute of element. More...
struct  _xmlID
 An XML ID instance. More...
struct  _xmlNode
 Generic node type in an XML or HTML tree. More...
struct  _xmlDoc
 An XML or HTML document. More...
struct  _xmlDOMWrapCtxt
 Context for DOM wrapper-operations. More...

Macros

#define LIBXML2_NEW_BUFFER
 Macro used to express that the API use the new buffers for xmlParserInputBuffer and xmlOutputBuffer.
#define XML_XML_NAMESPACE    (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
 This is the namespace for the special xml: prefix predefined in the XML Namespace specification.
#define XML_XML_ID   (const xmlChar *) "xml:id"
 This is the name for the special xml:id attribute.
#define XML_LOCAL_NAMESPACE   XML_NAMESPACE_DECL
 A namespace declaration node.
#define xmlChildrenNode   children
 Macro for compatibility naming layer with libxml1.
#define xmlRootNode   children
 Macro for compatibility naming layer with libxml1.

Typedefs

typedef struct _xmlParserInputBuffer xmlParserInputBuffer
 Parser input buffer.
typedef struct _xmlOutputBuffer xmlOutputBuffer
 Output buffer.
typedef struct _xmlParserInput xmlParserInput
 Parser input.
typedef struct _xmlParserCtxt xmlParserCtxt
 Parser context.
typedef struct _xmlSAXLocator xmlSAXLocator
 SAX locator.
typedef struct _xmlSAXHandler xmlSAXHandler
 SAX handler.
typedef struct _xmlEntity xmlEntity
 Entity declaration.
typedef struct _xmlBuffer xmlBuffer
 Buffer type.
typedef struct _xmlBuf xmlBuf
 Buffer with 64-bit support.
typedef struct _xmlNotation xmlNotation
 Notation declaration.
typedef struct _xmlEnumeration xmlEnumeration
 Enumeration in a DTD.
typedef struct _xmlAttribute xmlAttribute
 Attribute declaration.
typedef struct _xmlElementContent xmlElementContent
 Element content in element declarations.
typedef struct _xmlElement xmlElement
 Element declaration.
typedef struct _xmlNs xmlNs
 Namespace declaration.
typedef struct _xmlDtd xmlDtd
 Document type definition (DTD)
typedef struct _xmlAttr xmlAttr
 Attribute of an element.
typedef struct _xmlID xmlID
 Extra data for ID attributes.
typedef struct _xmlNode xmlNode
 Generic node type in an XML or HTML tree.
typedef struct _xmlDoc xmlDoc
 XML or HTML document.
typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt
 Context for DOM wrapper operations.
typedef xmlNs *(* xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxt *ctxt, xmlNode *node, const xmlChar *nsName, const xmlChar *nsPrefix)
 A function called to acquire namespaces (xmlNs) from the wrapper.
typedef void(* xmlRegisterNodeFunc) (xmlNode *node)
 Signature for the registration callback of a created node.
typedef void(* xmlDeregisterNodeFunc) (xmlNode *node)
 Signature for the deregistration callback of a discarded node.

Enumerations

enum  xmlBufferAllocationScheme
 Removed, buffers always use XML_BUFFER_ALLOC_IO now.
enum  xmlElementType
 The different element types carried by an XML tree. More...
enum  xmlAttributeType
 A DTD Attribute type definition.
enum  xmlAttributeDefault
 A DTD Attribute default definition.
enum  xmlElementContentType
 Possible definitions of element content types.
enum  xmlElementContentOccur
 Possible definitions of element content occurrences.
enum  xmlElementTypeVal
 The different possibilities for an element content type.
enum  xmlDocProperties
 Set of properties of the document as found by the parser. More...

Functions

int xmlValidateNCName (const xmlChar *value, int space)
 Check that a value conforms to the lexical space of NCName.
int xmlValidateQName (const xmlChar *value, int space)
 Check that a value conforms to the lexical space of QName.
int xmlValidateName (const xmlChar *value, int space)
 Check that a value conforms to the lexical space of Name.
int xmlValidateNMToken (const xmlChar *value, int space)
 Check that a value conforms to the lexical space of NMToken.
xmlCharxmlBuildQName (const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len)
 Build a QName from prefix and local name.
xmlCharxmlSplitQName2 (const xmlChar *name, xmlChar **prefix)
 Parse an XML qualified name.
const xmlCharxmlSplitQName3 (const xmlChar *name, int *len)
 Parse an XML qualified name.
xmlDtdxmlCreateIntSubset (xmlDoc *doc, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 Create a DTD node.
xmlDtdxmlNewDtd (xmlDoc *doc, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId)
 Create a DTD node.
xmlDtdxmlGetIntSubset (const xmlDoc *doc)
 Get the internal subset of a document.
void xmlFreeDtd (xmlDtd *cur)
 Free a DTD structure.
xmlNsxmlNewNs (xmlNode *node, const xmlChar *href, const xmlChar *prefix)
 Create a new namespace.
void xmlFreeNs (xmlNs *cur)
 Free an xmlNs object.
void xmlFreeNsList (xmlNs *cur)
 Free a list of xmlNs objects.
xmlDocxmlNewDoc (const xmlChar *version)
 Creates a new XML document.
void xmlFreeDoc (xmlDoc *cur)
 Free a document including all children and associated DTDs.
xmlAttrxmlNewDocProp (xmlDoc *doc, const xmlChar *name, const xmlChar *value)
 Create an attribute node.
xmlAttrxmlNewProp (xmlNode *node, const xmlChar *name, const xmlChar *value)
 Create an attribute node.
xmlAttrxmlNewNsProp (xmlNode *node, xmlNs *ns, const xmlChar *name, const xmlChar *value)
 Create an attribute node.
xmlAttrxmlNewNsPropEatName (xmlNode *node, xmlNs *ns, xmlChar *name, const xmlChar *value)
 Create an attribute node.
void xmlFreePropList (xmlAttr *cur)
 Free an attribute list including all children.
void xmlFreeProp (xmlAttr *cur)
 Free an attribute including all children.
xmlAttrxmlCopyProp (xmlNode *target, xmlAttr *cur)
 Create a copy of the attribute.
xmlAttrxmlCopyPropList (xmlNode *target, xmlAttr *cur)
 Create a copy of an attribute list.
xmlDtdxmlCopyDtd (xmlDtd *dtd)
 Copy a DTD.
xmlDocxmlCopyDoc (xmlDoc *doc, int recursive)
 Copy a document.
xmlNodexmlNewDocNode (xmlDoc *doc, xmlNs *ns, const xmlChar *name, const xmlChar *content)
 Create an element node.
xmlNodexmlNewDocNodeEatName (xmlDoc *doc, xmlNs *ns, xmlChar *name, const xmlChar *content)
 Create an element node.
xmlNodexmlNewNode (xmlNs *ns, const xmlChar *name)
 Create an element node.
xmlNodexmlNewNodeEatName (xmlNs *ns, xmlChar *name)
 Create an element node.
xmlNodexmlNewChild (xmlNode *parent, xmlNs *ns, const xmlChar *name, const xmlChar *content)
 Create a new child element and append it to a parent element.
xmlNodexmlNewDocText (const xmlDoc *doc, const xmlChar *content)
 Create a new text node.
xmlNodexmlNewText (const xmlChar *content)
 Create a text node.
xmlNodexmlNewDocPI (xmlDoc *doc, const xmlChar *name, const xmlChar *content)
 Create a processing instruction object.
xmlNodexmlNewPI (const xmlChar *name, const xmlChar *content)
 Create a processing instruction node.
xmlNodexmlNewDocTextLen (xmlDoc *doc, const xmlChar *content, int len)
 Create a new text node.
xmlNodexmlNewTextLen (const xmlChar *content, int len)
 Create a new text node.
xmlNodexmlNewDocComment (xmlDoc *doc, const xmlChar *content)
 Create a comment node.
xmlNodexmlNewComment (const xmlChar *content)
 Use of this function is DISCOURAGED in favor of xmlNewDocComment.
xmlNodexmlNewCDataBlock (xmlDoc *doc, const xmlChar *content, int len)
 Create a CDATA section node.
xmlNodexmlNewCharRef (xmlDoc *doc, const xmlChar *name)
 Create an empty entity reference node.
xmlNodexmlNewReference (const xmlDoc *doc, const xmlChar *name)
 Create a new entity reference node, linking the result with the entity in doc if found.
xmlNodexmlCopyNode (xmlNode *node, int recursive)
 Copy a node.
xmlNodexmlDocCopyNode (xmlNode *node, xmlDoc *doc, int recursive)
 Copy a node into another document.
xmlNodexmlDocCopyNodeList (xmlDoc *doc, xmlNode *node)
 Copy a node list and all children into a new document.
xmlNodexmlCopyNodeList (xmlNode *node)
 Copy a node list and all children.
xmlNodexmlNewTextChild (xmlNode *parent, xmlNs *ns, const xmlChar *name, const xmlChar *content)
 Create a new child element and append it to a parent element.
xmlNodexmlNewDocRawNode (xmlDoc *doc, xmlNs *ns, const xmlChar *name, const xmlChar *content)
 Create an element node.
xmlNodexmlNewDocFragment (xmlDoc *doc)
 Create a document fragment node.
long xmlGetLineNo (const xmlNode *node)
 Get line number of node.
xmlCharxmlGetNodePath (const xmlNode *node)
 Build a structure based Path for the given node.
xmlNodexmlDocGetRootElement (const xmlDoc *doc)
 Get the root element of the document.
xmlNodexmlGetLastChild (const xmlNode *parent)
 Find the last child of a node.
int xmlNodeIsText (const xmlNode *node)
 Check whether the node is a text node.
int xmlIsBlankNode (const xmlNode *node)
 Checks whether this node is an empty or whitespace-only text node.
xmlNodexmlDocSetRootElement (xmlDoc *doc, xmlNode *root)
 If root is NULL no action is taken.
void xmlNodeSetName (xmlNode *cur, const xmlChar *name)
 Set (or reset) the name of a node.
xmlNodexmlAddChild (xmlNode *parent, xmlNode *cur)
 Unlink cur and append it to the children of parent.
xmlNodexmlAddChildList (xmlNode *parent, xmlNode *cur)
 Append a node list to another node.
xmlNodexmlReplaceNode (xmlNode *old, xmlNode *cur)
 Unlink the old node.
xmlNodexmlAddPrevSibling (xmlNode *cur, xmlNode *elem)
 Unlinks cur and inserts it as previous sibling before next.
xmlNodexmlAddSibling (xmlNode *cur, xmlNode *elem)
 Unlinks cur and inserts it as last sibling of node.
xmlNodexmlAddNextSibling (xmlNode *cur, xmlNode *elem)
 Unlinks cur and inserts it as next sibling after prev.
void xmlUnlinkNode (xmlNode *cur)
 Unlink a node from its tree.
xmlNodexmlTextMerge (xmlNode *first, xmlNode *second)
 Merge the second text node into the first.
int xmlTextConcat (xmlNode *node, const xmlChar *content, int len)
 Concat the given string at the end of the existing node content.
void xmlFreeNodeList (xmlNode *cur)
 Free a node list including all children.
void xmlFreeNode (xmlNode *cur)
 Free a node including all the children.
int xmlSetTreeDoc (xmlNode *tree, xmlDoc *doc)
 Associate all nodes in a tree with a new document.
int xmlSetListDoc (xmlNode *list, xmlDoc *doc)
 Associate all subtrees in list with a new document.
xmlNsxmlSearchNs (xmlDoc *doc, xmlNode *node, const xmlChar *nameSpace)
 Search for a namespace with prefix in scope of node.
xmlNsxmlSearchNsByHref (xmlDoc *doc, xmlNode *node, const xmlChar *href)
 Search for a namespace matching URI in scope of node.
int xmlGetNsListSafe (const xmlDoc *doc, const xmlNode *node, xmlNs ***out)
 Find all in-scope namespaces of a node.
xmlNs ** xmlGetNsList (const xmlDoc *doc, const xmlNode *node)
 Find all in-scope namespaces of a node.
void xmlSetNs (xmlNode *node, xmlNs *ns)
 Set the namespace of an element or attribute node.
xmlNsxmlCopyNamespace (xmlNs *cur)
 Copy a namespace.
xmlNsxmlCopyNamespaceList (xmlNs *cur)
 Copy a namespace list.
xmlAttrxmlSetProp (xmlNode *node, const xmlChar *name, const xmlChar *value)
 Set (or reset) an element's attribute.
xmlAttrxmlSetNsProp (xmlNode *node, xmlNs *ns, const xmlChar *name, const xmlChar *value)
 Set (or reset) an element's attribute.
int xmlNodeGetAttrValue (const xmlNode *node, const xmlChar *name, const xmlChar *nsUri, xmlChar **out)
 Look up the value of an element's attribute.
xmlCharxmlGetNoNsProp (const xmlNode *node, const xmlChar *name)
 Look up the value of an element's attribute.
xmlCharxmlGetProp (const xmlNode *node, const xmlChar *name)
 Look up the value of an element's attribute.
xmlAttrxmlHasProp (const xmlNode *node, const xmlChar *name)
 Search for an attribute of an element.
xmlAttrxmlHasNsProp (const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
 Search for an attribute of an element.
xmlCharxmlGetNsProp (const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace)
 Look up the value of an element's attribute.
xmlNodexmlStringGetNodeList (const xmlDoc *doc, const xmlChar *value)
 Parse an attribute value and build a node list with text and entity reference nodes.
xmlNodexmlStringLenGetNodeList (const xmlDoc *doc, const xmlChar *value, int len)
 See xmlStringGetNodeList.
xmlCharxmlNodeListGetString (xmlDoc *doc, const xmlNode *list, int inLine)
 Serializes attribute children (text and entity reference nodes) into a string.
xmlCharxmlNodeListGetRawString (const xmlDoc *doc, const xmlNode *list, int inLine)
 Serializes attribute children (text and entity reference nodes) into a string.
int xmlNodeSetContent (xmlNode *cur, const xmlChar *content)
 Replace the text content of a node.
int xmlNodeSetContentLen (xmlNode *cur, const xmlChar *content, int len)
 See xmlNodeSetContent.
int xmlNodeAddContent (xmlNode *cur, const xmlChar *content)
 Append the extra substring to the node content.
int xmlNodeAddContentLen (xmlNode *cur, const xmlChar *content, int len)
 Append the extra substring to the node content.
xmlCharxmlNodeGetContent (const xmlNode *cur)
 Returns the string value of a node.
int xmlNodeBufGetContent (xmlBuffer *buffer, const xmlNode *cur)
 Append the string value of a node to buffer.
int xmlBufGetNodeContent (xmlBuf *buf, const xmlNode *cur)
 Append the string value of a node to buf.
xmlCharxmlNodeGetLang (const xmlNode *cur)
 Find the xml:lang of a node.
int xmlNodeGetSpacePreserve (const xmlNode *cur)
 Find the xml:space of a node.
int xmlNodeSetLang (xmlNode *cur, const xmlChar *lang)
 Set the xml:lang attribute of a node.
int xmlNodeSetSpacePreserve (xmlNode *cur, int val)
 Set the xml:space attribute of a node.
int xmlNodeGetBaseSafe (const xmlDoc *doc, const xmlNode *cur, xmlChar **baseOut)
 Searches for the base URI.
xmlCharxmlNodeGetBase (const xmlDoc *doc, const xmlNode *cur)
 See xmlNodeGetBaseSafe.
int xmlNodeSetBase (xmlNode *cur, const xmlChar *uri)
 Set (or reset) the base URI of a node, i.e.
int xmlRemoveProp (xmlAttr *cur)
 Unlink and free an attribute including all children.
int xmlUnsetNsProp (xmlNode *node, xmlNs *ns, const xmlChar *name)
 Remove an attribute of an element.
int xmlUnsetProp (xmlNode *node, const xmlChar *name)
 Remove an attribute of an element.
void xmlAttrSerializeTxtContent (xmlBuffer *buf, xmlDoc *doc, xmlAttr *attr, const xmlChar *string)
 Serialize attribute text to an xmlBuffer.
int xmlReconciliateNs (xmlDoc *doc, xmlNode *tree)
 This function checks that all the namespaces declared within the given tree are properly declared.
void xmlDocDumpFormatMemory (xmlDoc *cur, xmlChar **mem, int *size, int format)
 Same as xmlDocDumpFormatMemoryEnc with encoding set to NULL.
void xmlDocDumpMemory (xmlDoc *cur, xmlChar **mem, int *size)
 Same as xmlDocDumpFormatMemoryEnc with encoding set to NULL and format set to 0.
void xmlDocDumpMemoryEnc (xmlDoc *out_doc, xmlChar **doc_txt_ptr, int *doc_txt_len, const char *txt_encoding)
 Same as xmlDocDumpFormatMemoryEnc with format set to 0.
void xmlDocDumpFormatMemoryEnc (xmlDoc *out_doc, xmlChar **doc_txt_ptr, int *doc_txt_len, const char *txt_encoding, int format)
 Serialize an XML document to memory.
int xmlDocFormatDump (FILE *f, xmlDoc *cur, int format)
 Serialize an XML document to a FILE.
int xmlDocDump (FILE *f, xmlDoc *cur)
 Serialize an XML document to a FILE.
void xmlElemDump (FILE *f, xmlDoc *doc, xmlNode *cur)
 Serialize an XML node to a FILE.
int xmlSaveFile (const char *filename, xmlDoc *cur)
 Same as xmlSaveFormatFileEnc with encoding set to NULL and format set to 0.
int xmlSaveFormatFile (const char *filename, xmlDoc *cur, int format)
 Same as xmlSaveFormatFileEnc with encoding set to NULL.
size_t xmlBufNodeDump (xmlBuf *buf, xmlDoc *doc, xmlNode *cur, int level, int format)
 Serialize an XML node to an xmlBuf.
int xmlNodeDump (xmlBuffer *buf, xmlDoc *doc, xmlNode *cur, int level, int format)
 Serialize an XML node to an xmlBuffer.
int xmlSaveFileTo (xmlOutputBuffer *buf, xmlDoc *cur, const char *encoding)
 Same as xmlSaveFormatFileTo with format set to 0.
int xmlSaveFormatFileTo (xmlOutputBuffer *buf, xmlDoc *cur, const char *encoding, int format)
 Serialize an XML document to an output buffer.
void xmlNodeDumpOutput (xmlOutputBuffer *buf, xmlDoc *doc, xmlNode *cur, int level, int format, const char *encoding)
 Serialize an XML node to an output buffer.
int xmlSaveFormatFileEnc (const char *filename, xmlDoc *cur, const char *encoding, int format)
 Serialize an XML document to a file using the given encoding.
int xmlSaveFileEnc (const char *filename, xmlDoc *cur, const char *encoding)
 Same as xmlSaveFormatFileEnc with format set to 0.
int xmlIsXHTML (const xmlChar *systemID, const xmlChar *publicID)
 Try to find if the document correspond to an XHTML DTD.
int xmlGetDocCompressMode (const xmlDoc *doc)
 Get the compression level of a document, ZLIB based.
void xmlSetDocCompressMode (xmlDoc *doc, int mode)
 Set the compression level of a document, ZLIB based.
int xmlGetCompressMode (void)
 Get the global compression level, ZLIB based.
void xmlSetCompressMode (int mode)
 Set the global compression level, ZLIB based.
xmlDOMWrapCtxtxmlDOMWrapNewCtxt (void)
 Allocates and initializes a new DOM-wrapper context.
void xmlDOMWrapFreeCtxt (xmlDOMWrapCtxt *ctxt)
 Frees the DOM-wrapper context.
int xmlDOMWrapReconcileNamespaces (xmlDOMWrapCtxt *ctxt, xmlNode *elem, int options)
 Fix up namespaces.
int xmlDOMWrapAdoptNode (xmlDOMWrapCtxt *ctxt, xmlDoc *sourceDoc, xmlNode *node, xmlDoc *destDoc, xmlNode *destParent, int options)
 Fix up namespaces before moving a node.
int xmlDOMWrapRemoveNode (xmlDOMWrapCtxt *ctxt, xmlDoc *doc, xmlNode *node, int options)
 Unlinks the given node from its owner.
int xmlDOMWrapCloneNode (xmlDOMWrapCtxt *ctxt, xmlDoc *sourceDoc, xmlNode *node, xmlNode **clonedNode, xmlDoc *destDoc, xmlNode *destParent, int deep, int options)
 Clone a node and fix namespaces.
unsigned long xmlChildElementCount (xmlNode *parent)
 Count the number of child nodes which are elements.
xmlNodexmlNextElementSibling (xmlNode *node)
 Find the closest following sibling which is a element.
xmlNodexmlFirstElementChild (xmlNode *parent)
 Find the first child node which is an element.
xmlNodexmlLastElementChild (xmlNode *parent)
 Find the last child node which is an element.
xmlNodexmlPreviousElementSibling (xmlNode *node)
 Find the closest preceding sibling which is a element.
xmlRegisterNodeFunc xmlRegisterNodeDefault (xmlRegisterNodeFunc func)
 Registers a callback for node creation.
xmlDeregisterNodeFunc xmlDeregisterNodeDefault (xmlDeregisterNodeFunc func)
 Registers a callback for node destruction.
xmlRegisterNodeFunc xmlThrDefRegisterNodeDefault (xmlRegisterNodeFunc func)
 Set per-thread default value.
xmlDeregisterNodeFunc xmlThrDefDeregisterNodeDefault (xmlDeregisterNodeFunc func)
 Set per-thread default value.
void xmlSetBufferAllocationScheme (xmlBufferAllocationScheme scheme)
 Set the buffer allocation scheme.
xmlBufferAllocationScheme xmlGetBufferAllocationScheme (void)
 Get the buffer allocation scheme.
xmlBufferxmlBufferCreate (void)
 Create a buffer.
xmlBufferxmlBufferCreateSize (size_t size)
 Create a buffer with an initial size.
xmlBufferxmlBufferCreateStatic (void *mem, size_t size)
 Create a static buffer.
int xmlBufferResize (xmlBuffer *buf, unsigned int size)
 Resize a buffer to a minimum size.
void xmlBufferFree (xmlBuffer *buf)
 Free a buffer.
int xmlBufferDump (FILE *file, xmlBuffer *buf)
 Dump a buffer to a FILE.
int xmlBufferAdd (xmlBuffer *buf, const xmlChar *str, int len)
 Append bytes to a buffer.
int xmlBufferAddHead (xmlBuffer *buf, const xmlChar *str, int len)
 Prepend bytes to a buffer.
int xmlBufferCat (xmlBuffer *buf, const xmlChar *str)
 Append a zero-terminated string to a buffer.
int xmlBufferCCat (xmlBuffer *buf, const char *str)
 Append a zero-terminated C string to a buffer.
int xmlBufferShrink (xmlBuffer *buf, unsigned int len)
 Discard bytes at the start of a buffer.
int xmlBufferGrow (xmlBuffer *buf, unsigned int len)
 Grow a buffer.
void xmlBufferEmpty (xmlBuffer *buf)
 Empty a buffer.
const xmlCharxmlBufferContent (const xmlBuffer *buf)
 Get pointer into buffer content.
xmlCharxmlBufferDetach (xmlBuffer *buf)
 Extract buffer content.
void xmlBufferSetAllocationScheme (xmlBuffer *buf, xmlBufferAllocationScheme scheme)
 Set the allocation scheme of a buffer.
int xmlBufferLength (const xmlBuffer *buf)
 Get the size of the buffer content.
void xmlBufferWriteCHAR (xmlBuffer *buf, const xmlChar *string)
 Append a zero-terminated xmlChar string to a buffer.
void xmlBufferWriteChar (xmlBuffer *buf, const char *string)
 Append a zero-terminated C string to a buffer.
void xmlBufferWriteQuotedString (xmlBuffer *buf, const xmlChar *string)
 Append a quoted string to a buffer.
xmlCharxmlBufContent (const xmlBuf *buf)
 Get pointer into buffer content.
xmlCharxmlBufEnd (xmlBuf *buf)
 Return a pointer to the end of the buffer content.
size_t xmlBufUse (xmlBuf *buf)
 Return the size of the buffer content.
size_t xmlBufShrink (xmlBuf *buf, size_t len)
 Discard bytes at the start of a buffer.

Detailed Description

Document tree API.

Data structures and functions to build, modify, query and serialize XML and HTML document trees. Also contains the buffer API.

Author
Daniel Veillard

Macro Definition Documentation

◆ LIBXML2_NEW_BUFFER

#define LIBXML2_NEW_BUFFER

Macro used to express that the API use the new buffers for xmlParserInputBuffer and xmlOutputBuffer.

The change was introduced in 2.9.0.

◆ xmlChildrenNode

#define xmlChildrenNode   children

Macro for compatibility naming layer with libxml1.

Maps to "children."

◆ xmlRootNode

#define xmlRootNode   children

Macro for compatibility naming layer with libxml1.

Maps to "children".

Typedef Documentation

◆ xmlDeregisterNodeFunc

typedef void(* xmlDeregisterNodeFunc) (xmlNode *node)

Signature for the deregistration callback of a discarded node.

Parameters
nodethe current node

◆ xmlDOMWrapAcquireNsFunction

typedef xmlNs *(* xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxt *ctxt, xmlNode *node, const xmlChar *nsName, const xmlChar *nsPrefix)

A function called to acquire namespaces (xmlNs) from the wrapper.

Parameters
ctxta DOM wrapper context
nodethe context node (element or attribute)
nsNamethe requested namespace name
nsPrefixthe requested namespace prefix
Returns
an xmlNs or NULL in case of an error.

◆ xmlParserInputBuffer

Parser input buffer.

This struct and all related functions should ultimately be removed from the public interface.

◆ xmlRegisterNodeFunc

typedef void(* xmlRegisterNodeFunc) (xmlNode *node)

Signature for the registration callback of a created node.

Parameters
nodethe current node

Enumeration Type Documentation

◆ xmlDocProperties

Set of properties of the document as found by the parser.

Some of them are linked to similarly named xmlParserOption.

Enumerator
XML_DOC_WELLFORMED 

document is XML well formed

XML_DOC_NSVALID 

document is Namespace valid

XML_DOC_OLD10 

parsed with old XML-1.0 parser

XML_DOC_DTDVALID 

DTD validation was successful.

XML_DOC_XINCLUDE 

XInclude substitution was done.

XML_DOC_USERBUILT 

Document was built using the API and not by parsing an instance.

XML_DOC_INTERNAL 

built for internal processing

XML_DOC_HTML 

parsed or built HTML document

◆ xmlElementType

The different element types carried by an XML tree.

NOTE: This is synchronized with DOM Level 1 values. See http://www.w3.org/TR/REC-DOM-Level-1/

Actually this had diverged a bit, and XML_DTD_NODE is used instead of XML_DOCUMENT_TYPE_NODE.

Enumerator
XML_ELEMENT_NODE 

An element.

Objects of this type are an xmlNode.

XML_ATTRIBUTE_NODE 

An attribute.

Objects of this type are an xmlAttr.

XML_TEXT_NODE 

A text node.

Objects of this type are an xmlNode.

XML_CDATA_SECTION_NODE 

A CDATA section.

Objects of this type are an xmlNode.

XML_ENTITY_REF_NODE 

An entity reference.

Objects of this type are an xmlNode. The children member points to the entity declaration if available.

XML_ENTITY_NODE 

unused

XML_PI_NODE 

A processing instruction.

Objects of this type are an xmlNode.

XML_COMMENT_NODE 

A comment.

Objects of this type are an xmlNode.

XML_DOCUMENT_NODE 

A document.

Objects of this type are an xmlDoc.

XML_DOCUMENT_TYPE_NODE 

unused

XML_DOCUMENT_FRAG_NODE 

A document fragment.

Objects of this type are an xmlNode.

XML_NOTATION_NODE 

A notation, unused.

XML_HTML_DOCUMENT_NODE 

An HTML document.

Objects of this type are an xmlDoc.

XML_DTD_NODE 

A document type definition.

Objects of this type are an xmlDtd.

XML_ELEMENT_DECL 

An element declaration.

Objects of this type are an xmlElement.

XML_ATTRIBUTE_DECL 

An attribute declaration.

Objects of this type are an xmlAttribute.

XML_ENTITY_DECL 

An entity declaration.

Objects of this type are an xmlEntity.

XML_NAMESPACE_DECL 

An XPath namespace node.

Can only be returned by the XPath engine. Objects of this type are an xmlNs which has a completely different layout than xmlNode. The next member contains a pointer to the xmlNode element to which the namespace applies.

Nodes of this type must be handled with extreme care to avoid type confusion bugs.

XML_XINCLUDE_START 

An XInclude start marker.

Objects of this type are an xmlNode. Inserted as preceding sibling of XIncluded content.

XML_XINCLUDE_END 

An XInclude end marker.

Objects of this type are an xmlNode. Inserted as following sibling of XIncluded content.

Function Documentation

◆ xmlAddChild()

xmlNode * xmlAddChild ( xmlNode * parent,
xmlNode * cur )

Unlink cur and append it to the children of parent.

If cur is a text node, it may be merged with an adjacent text node and freed. In this case the text node containing the merged content is returned.

If cur is an attribute node, it is appended to the attributes of parent. If the attribute list contains an attribute with a name matching cur, the old attribute is destroyed.

Before version 2.13, this function didn't unlink cur before moving it. Callers must unlink the node manually if it has siblings.

General notes:

Move operations like xmlAddChild can cause element or attribute nodes to reference namespaces that aren't declared in one of their ancestors. This can lead to use-after-free errors if the elements containing the declarations are freed later, especially when moving nodes from one document to another. You should consider calling xmlReconciliateNs after a move operation to normalize namespaces. Another option is to call xmlDOMWrapAdoptNode with the target parent before moving a node.

For the most part, move operations don't check whether the resulting tree structure is valid. Users must make sure that parent nodes only receive children of valid types. Inserted child nodes must never be an ancestor of the parent node to avoid cycles in the tree structure. In general, only document, document fragments, elements and attributes should be used as parent nodes.

When moving a node between documents and a memory allocation fails, the node's content will be corrupted and it will be unlinked. In this case, the node must be freed manually.

Moving DTDs between documents isn't supported.

Parameters
parentthe parent node
curthe child node
Returns
cur or a sibling if cur was merged. Returns NULL if arguments are invalid or a memory allocation failed.

◆ xmlAddChildList()

xmlNode * xmlAddChildList ( xmlNode * parent,
xmlNode * cur )

Append a node list to another node.

See xmlAddChild.

Parameters
parentthe parent node
curthe first node in the list
Returns
the last child or NULL in case of error.

◆ xmlAddNextSibling()

xmlNode * xmlAddNextSibling ( xmlNode * prev,
xmlNode * cur )

Unlinks cur and inserts it as next sibling after prev.

Unlike xmlAddChild this function does not merge text nodes.

If cur is an attribute node, it is inserted after attribute prev. If the attribute list contains an attribute with a name matching cur, the old attribute is destroyed.

See the notes in xmlAddChild.

Parameters
prevthe target node
curthe new node
Returns
cur or a sibling if cur was merged. Returns NULL if arguments are invalid or a memory allocation failed.

◆ xmlAddPrevSibling()

xmlNode * xmlAddPrevSibling ( xmlNode * next,
xmlNode * cur )

Unlinks cur and inserts it as previous sibling before next.

Unlike xmlAddChild this function does not merge text nodes.

If cur is an attribute node, it is inserted before attribute next. If the attribute list contains an attribute with a name matching cur, the old attribute is destroyed.

See the notes in xmlAddChild.

Parameters
nextthe target node
curthe new node
Returns
cur or a sibling if cur was merged. Returns NULL if arguments are invalid or a memory allocation failed.

◆ xmlAddSibling()

xmlNode * xmlAddSibling ( xmlNode * node,
xmlNode * cur )

Unlinks cur and inserts it as last sibling of node.

If cur is a text node, it may be merged with an adjacent text node and freed. In this case the text node containing the merged content is returned.

If cur is an attribute node, it is appended to the attribute list containing node. If the attribute list contains an attribute with a name matching cur, the old attribute is destroyed.

See the notes in xmlAddChild.

Parameters
nodethe target node
curthe new node
Returns
cur or a sibling if cur was merged. Returns NULL if arguments are invalid or a memory allocation failed.

◆ xmlAttrSerializeTxtContent()

void xmlAttrSerializeTxtContent ( xmlBuffer * buf,
xmlDoc * doc,
xmlAttr * attr,
const xmlChar * string )

Serialize attribute text to an xmlBuffer.

Parameters
bufthe XML buffer output
docthe document
attrthe attribute node
stringthe text content

◆ xmlBufContent()

xmlChar * xmlBufContent ( const xmlBuf * buf)

Get pointer into buffer content.

Parameters
bufthe buffer
Returns
the internal content or NULL in case of error

◆ xmlBufEnd()

xmlChar * xmlBufEnd ( xmlBuf * buf)

Return a pointer to the end of the buffer content.

Parameters
bufthe buffer
Returns
the end of the internal content or NULL in case of error

◆ xmlBufferAdd()

int xmlBufferAdd ( xmlBuffer * buf,
const xmlChar * str,
int len )

Append bytes to a buffer.

If len is -1, str is assumed to be zero-terminated.

Parameters
bufthe buffer
strbytes to add
lennumber of bytes
Returns
an xmlParserErrors code.

◆ xmlBufferAddHead()

int xmlBufferAddHead ( xmlBuffer * buf,
const xmlChar * str,
int len )

Prepend bytes to a buffer.

If len is -1, str is assumed to be zero-terminated.

Parameters
bufthe buffer
strbytes to prepend
lennumber of bytes
Returns
an xmlParserErrors code.

◆ xmlBufferCat()

int xmlBufferCat ( xmlBuffer * buf,
const xmlChar * str )

Append a zero-terminated string to a buffer.

Parameters
bufthe buffer
strstring to add
Returns
an xmlParserErrors code.

◆ xmlBufferCCat()

int xmlBufferCCat ( xmlBuffer * buf,
const char * str )

Append a zero-terminated C string to a buffer.

Parameters
bufthe buffer
strstring to add
Returns
an xmlParserErrors code.

◆ xmlBufferContent()

const xmlChar * xmlBufferContent ( const xmlBuffer * buf)

Get pointer into buffer content.

Parameters
bufthe buffer
Returns
the internal content

◆ xmlBufferCreate()

xmlBuffer * xmlBufferCreate ( void )

Create a buffer.

The default initial size is 256.

Returns
the new structure.

◆ xmlBufferCreateSize()

xmlBuffer * xmlBufferCreateSize ( size_t size)

Create a buffer with an initial size.

Parameters
sizeinitial size of buffer
Returns
the new structure.

◆ xmlBufferCreateStatic()

xmlBuffer * xmlBufferCreateStatic ( void * mem,
size_t size )

Create a static buffer.

The memory must be zero-terminated and not be modified for the lifetime of the buffer. A static buffer can't be grown, modified or detached, but it can be shrunk.

Parameters
memthe memory area
sizethe size in bytes
Returns
a new buffer

◆ xmlBufferDetach()

xmlChar * xmlBufferDetach ( xmlBuffer * buf)

Extract buffer content.

Return the contents of the buffer as an xmlChar string, clearing the buffer.

This doesn't work with static buffers as they can't be reset.

Parameters
bufthe buffer
Returns
the buffer content

◆ xmlBufferDump()

int xmlBufferDump ( FILE * file,
xmlBuffer * buf )

Dump a buffer to a FILE.

Parameters
filethe output file
bufthe buffer
Returns
the number of bytes written

◆ xmlBufferEmpty()

void xmlBufferEmpty ( xmlBuffer * buf)

Empty a buffer.

Parameters
bufthe buffer

◆ xmlBufferFree()

void xmlBufferFree ( xmlBuffer * buf)

Free a buffer.

Parameters
bufthe buffer to free

◆ xmlBufferGrow()

int xmlBufferGrow ( xmlBuffer * buf,
unsigned int len )

Grow a buffer.

Deprecated
Internal function, don't use.
Parameters
bufthe buffer
lennumber of extra bytes to allocate
Returns
the new available space or -1 in case of error

◆ xmlBufferLength()

int xmlBufferLength ( const xmlBuffer * buf)

Get the size of the buffer content.

Parameters
bufthe buffer
Returns
the size of the buffer content in bytes

◆ xmlBufferResize()

int xmlBufferResize ( xmlBuffer * buf,
unsigned int size )

Resize a buffer to a minimum size.

Deprecated
Internal function, don't use.
Parameters
bufthe buffer to resize
sizethe desired size
Returns
1 on succes, 0 in case of error

◆ xmlBufferSetAllocationScheme()

void xmlBufferSetAllocationScheme ( xmlBuffer * buf,
xmlBufferAllocationScheme scheme )

Set the allocation scheme of a buffer.

For libxml2 before 2.14, it is recommended to set this to XML_BUFFER_ALLOC_DOUBLE_IT. Has no effect on 2.14 or later.

Parameters
bufthe buffer to tune
schemeallocation scheme to use

◆ xmlBufferShrink()

int xmlBufferShrink ( xmlBuffer * buf,
unsigned int len )

Discard bytes at the start of a buffer.

Deprecated
Internal function, don't use.
Parameters
bufthe buffer
lenthe number of bytes to remove
Returns
the number of bytes removed, or -1 in case of failure.

◆ xmlBufferWriteCHAR()

void xmlBufferWriteCHAR ( xmlBuffer * buf,
const xmlChar * string )

Append a zero-terminated xmlChar string to a buffer.

Parameters
bufthe XML buffer
stringthe string to add

◆ xmlBufferWriteChar()

void xmlBufferWriteChar ( xmlBuffer * buf,
const char * string )

Append a zero-terminated C string to a buffer.

Same as xmlBufferCCat.

Parameters
bufthe buffer
stringthe string to add

◆ xmlBufferWriteQuotedString()

void xmlBufferWriteQuotedString ( xmlBuffer * buf,
const xmlChar * string )

Append a quoted string to a buffer.

Append a string quoted with single or double quotes. If the string contains both single and double quotes, double quotes are escaped with &quot;.

Parameters
bufthe buffer
stringthe string to add

◆ xmlBufGetNodeContent()

int xmlBufGetNodeContent ( xmlBuf * buf,
const xmlNode * cur )

Append the string value of a node to buf.

For text nodes, the string value is the text content. Otherwise, the string value is the concatenation of the string values of the node's descendants.

Entity references are substituted.

Parameters
bufa buffer xmlBuf
curthe node being read
Returns
0 in case of success and -1 in case of error.

◆ xmlBufNodeDump()

size_t xmlBufNodeDump ( xmlBuf * buf,
xmlDoc * doc,
xmlNode * cur,
int level,
int format )

Serialize an XML node to an xmlBuf.

Uses the document's encoding. If the document has no encoding, uses ASCII without an encoding declaration.

Note that format only works if the document was parsed with XML_PARSE_NOBLANKS.

Parameters
bufthe XML buffer output
docthe document
curthe current node
levelthe imbrication level for indenting
formatis formatting allowed
Returns
the number of bytes written to the buffer, in case of error 0 is returned or buf stores the error

◆ xmlBufShrink()

size_t xmlBufShrink ( xmlBuf * buf,
size_t len )

Discard bytes at the start of a buffer.

NOTE that the return value differs from xmlBufferShrink as it will return 0 on error instead of -1 due to size_t being used as the return type.

Deprecated
Internal function, don't use.
Parameters
bufthe buffer
lenthe number of bytes to remove
Returns
the number of bytes removed or 0 in case of failure

◆ xmlBufUse()

size_t xmlBufUse ( xmlBuf * buf)

Return the size of the buffer content.

Parameters
bufthe buffer
Returns
size of buffer content in bytes

◆ xmlBuildQName()

xmlChar * xmlBuildQName ( const xmlChar * ncname,
const xmlChar * prefix,
xmlChar * memory,
int len )

Build a QName from prefix and local name.

Builds the QName prefix:ncname in memory if there is enough space and prefix is not NULL nor empty, otherwise allocate a new string. If prefix is NULL or empty it returns ncname.

Parameters
ncnamethe Name
prefixthe prefix
memorypreallocated memory
lenpreallocated memory length
Returns
the new string which must be freed by the caller if different from memory and ncname or NULL in case of error

◆ xmlChildElementCount()

unsigned long xmlChildElementCount ( xmlNode * parent)

Count the number of child nodes which are elements.

Note that entity references are not expanded.

Parameters
parentthe parent node
Returns
the number of element children or 0 if arguments are invalid.

◆ xmlCopyDoc()

xmlDoc * xmlCopyDoc ( xmlDoc * doc,
int recursive )

Copy a document.

If recursive, the content tree will be copied too as well as DTD, namespaces and entities.

Parameters
docthe document
recursiveif not zero do a recursive copy.
Returns
the copied document or NULL if a memory allocation failed.

◆ xmlCopyDtd()

xmlDtd * xmlCopyDtd ( xmlDtd * dtd)

Copy a DTD.

Parameters
dtdthe DTD
Returns
the copied DTD or NULL if a memory allocation failed.

◆ xmlCopyNamespace()

xmlNs * xmlCopyNamespace ( xmlNs * cur)

Copy a namespace.

Parameters
curthe namespace
Returns
the copied namespace or NULL if a memory allocation failed.

◆ xmlCopyNamespaceList()

xmlNs * xmlCopyNamespaceList ( xmlNs * cur)

Copy a namespace list.

Parameters
curthe first namespace
Returns
the head of the copied list or NULL if a memory allocation failed.

◆ xmlCopyNode()

xmlNode * xmlCopyNode ( xmlNode * node,
int extended )

Copy a node.

If extended is 0, make a shallow copy.

If extended is 1, make a deep copy (properties, namespaces and children when applicable).

If extended is 2, make a shallow copy including properties and namespaces of elements.

Use of this function is DISCOURAGED in favor of xmlDocCopyNode.

Parameters
nodethe node
extendedmode of operation
Returns
the copied node or NULL if a memory allocation failed.

◆ xmlCopyNodeList()

xmlNode * xmlCopyNodeList ( xmlNode * node)

Copy a node list and all children.

Use of this function is DISCOURAGED in favor of xmlDocCopyNodeList.

Parameters
nodethe first node in the list.
Returns
the head of the copied list or NULL if a memory allocation failed.

◆ xmlCopyProp()

xmlAttr * xmlCopyProp ( xmlNode * target,
xmlAttr * cur )

Create a copy of the attribute.

This function sets the parent pointer of the copy to target but doesn't set the attribute on the target element. Users should consider to set the attribute by calling xmlAddChild afterwards or reset the parent pointer to NULL.

Parameters
targetthe element where the attribute will be grafted
curthe attribute
Returns
the copied attribute or NULL if a memory allocation failed.

◆ xmlCopyPropList()

xmlAttr * xmlCopyPropList ( xmlNode * target,
xmlAttr * cur )

Create a copy of an attribute list.

This function sets the parent pointers of the copied attributes to target but doesn't set the attributes on the target element.

Parameters
targetthe element where the attributes will be grafted
curthe first attribute
Returns
the head of the copied list or NULL if a memory allocation failed.

◆ xmlCreateIntSubset()

xmlDtd * xmlCreateIntSubset ( xmlDoc * doc,
const xmlChar * name,
const xmlChar * publicId,
const xmlChar * systemId )

Create a DTD node.

If a document is provided and it already has an internal subset, the existing DTD object is returned without creating a new object. If the document has no internal subset, it will be set to the created DTD.

Parameters
docthe document pointer (optional)
namethe DTD name (optional)
publicIdpublic identifier of the DTD (optional)
systemIdsystem identifier (URL) of the DTD (optional)
Returns
a pointer to the new or existing DTD object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlDeregisterNodeDefault()

xmlDeregisterNodeFunc xmlDeregisterNodeDefault ( xmlDeregisterNodeFunc func)

Registers a callback for node destruction.

Deprecated
don't use
Parameters
funcfunction pointer to the new DeregisterNodeFunc
Returns
the previous value of the deregistration function

◆ xmlDocCopyNode()

xmlNode * xmlDocCopyNode ( xmlNode * node,
xmlDoc * doc,
int extended )

Copy a node into another document.

If extended is 0, make a shallow copy.

If extended is 1, make a deep copy (properties, namespaces and children when applicable).

If extended is 2, make a shallow copy including properties and namespaces of elements.

Parameters
nodethe node
docthe document
extendedmode of operation
Returns
the copied node or NULL if a memory allocation failed.

◆ xmlDocCopyNodeList()

xmlNode * xmlDocCopyNodeList ( xmlDoc * doc,
xmlNode * node )

Copy a node list and all children into a new document.

Parameters
docthe target document
nodethe first node in the list.
Returns
the head of the copied list or NULL if a memory allocation failed.

◆ xmlDocDump()

int xmlDocDump ( FILE * f,
xmlDoc * cur )

Serialize an XML document to a FILE.

Uses the document's encoding. If the document has no encoding, uses ASCII without an encoding declaration.

Parameters
fthe FILE*
curthe document
Returns
the number of bytes written or -1 in case of failure.

◆ xmlDocDumpFormatMemory()

void xmlDocDumpFormatMemory ( xmlDoc * cur,
xmlChar ** mem,
int * size,
int format )

Same as xmlDocDumpFormatMemoryEnc with encoding set to NULL.

Parameters
curthe document
memOUT: the memory pointer
sizeOUT: the memory length
formatshould formatting spaces been added

◆ xmlDocDumpFormatMemoryEnc()

void xmlDocDumpFormatMemoryEnc ( xmlDoc * out_doc,
xmlChar ** doc_txt_ptr,
int * doc_txt_len,
const char * txt_encoding,
int format )

Serialize an XML document to memory.

If encoding is NULL, uses the document's encoding. If the document has no encoding, serializes as ASCII without an encoding declaration.

It is up to the caller of this function to free the returned memory with xmlFree.

Note that format only works if the document was parsed with XML_PARSE_NOBLANKS.

Parameters
out_docDocument to generate XML text from
doc_txt_ptrMemory pointer for allocated XML text
doc_txt_lenLength of the generated XML text
txt_encodingCharacter encoding to use when generating XML text
formatshould formatting spaces been added

◆ xmlDocDumpMemory()

void xmlDocDumpMemory ( xmlDoc * cur,
xmlChar ** mem,
int * size )

Same as xmlDocDumpFormatMemoryEnc with encoding set to NULL and format set to 0.

Parameters
curthe document
memOUT: the memory pointer
sizeOUT: the memory length

◆ xmlDocDumpMemoryEnc()

void xmlDocDumpMemoryEnc ( xmlDoc * out_doc,
xmlChar ** doc_txt_ptr,
int * doc_txt_len,
const char * txt_encoding )

Same as xmlDocDumpFormatMemoryEnc with format set to 0.

Parameters
out_docDocument to generate XML text from
doc_txt_ptrMemory pointer for allocated XML text
doc_txt_lenLength of the generated XML text
txt_encodingCharacter encoding to use when generating XML text

◆ xmlDocFormatDump()

int xmlDocFormatDump ( FILE * f,
xmlDoc * cur,
int format )

Serialize an XML document to a FILE.

Uses the document's encoding. If the document has no encoding, uses ASCII without an encoding declaration.

Note that format only works if the document was parsed with XML_PARSE_NOBLANKS.

Parameters
fthe FILE*
curthe document
formatshould formatting spaces been added
Returns
the number of bytes written or -1 in case of failure.

◆ xmlDocGetRootElement()

xmlNode * xmlDocGetRootElement ( const xmlDoc * doc)

Get the root element of the document.

Searches the document's children for the root element. The first child is not necessarily the root element, but could also be a DTD, comment or PI.

Parameters
docthe document
Returns
the root element or NULL if no element was found.

◆ xmlDocSetRootElement()

xmlNode * xmlDocSetRootElement ( xmlDoc * doc,
xmlNode * root )

If root is NULL no action is taken.

To remove a node from a document, use xmlUnlinkNode instead.

Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...).

root must be an element node. It is unlinked before insertion.

Parameters
docthe document
rootthe new document root element
Returns
the unlinked old root element or NULL if the document didn't have a root element or a memory allocation failed.

◆ xmlDOMWrapAdoptNode()

int xmlDOMWrapAdoptNode ( xmlDOMWrapCtxt * ctxt,
xmlDoc * sourceDoc,
xmlNode * node,
xmlDoc * destDoc,
xmlNode * destParent,
int options )

Fix up namespaces before moving a node.

References of out-of scope ns-decls are remapped to point to destDoc: If destParent is given, then nsDef entries on element-nodes are used. If no destParent is given, then destDoc->oldNs entries are used This is the case when you have an unlinked node and just want to move it to the context of.

If destParent is given, it ensures that the tree is namespace wellformed by creating additional ns-decls where needed. Note that, since prefixes of already existent ns-decls can be shadowed by this process, it could break QNames in attribute values or element content.

NOTE: This function was not intensively tested.

Parameters
ctxtthe optional context for custom processing
sourceDocthe optional sourceDoc
nodethe node to start with
destDocthe destination doc
destParentthe optional new parent of node in destDoc
optionsoption flags
Returns
0 if the operation succeeded, 1 if a node of unsupported type was given, 2 if a node of not yet supported type was given and -1 on API/internal errors.

◆ xmlDOMWrapCloneNode()

int xmlDOMWrapCloneNode ( xmlDOMWrapCtxt * ctxt,
xmlDoc * sourceDoc,
xmlNode * node,
xmlNode ** resNode,
xmlDoc * destDoc,
xmlNode * destParent,
int deep,
int options )

Clone a node and fix namespaces.

References of out-of scope ns-decls are remapped to point to destDoc. If destParent is given, then nsDef entries on element-nodes are used. If no destParent is given, then destDoc->oldNs entries are used. This is the case when you don't know already where the cloned branch will be added to.

If destParent is given, it ensures that the tree is namespace wellformed by creating additional ns-decls where needed. Note that, since prefixes of already existent ns-decls can be shadowed by this process, it could break QNames in attribute values or element content.

Parameters
ctxtthe optional context for custom processing
sourceDocthe optional sourceDoc
nodethe node to start with
resNodethe clone of the given node
destDocthe destination doc
destParentthe optional new parent of node in destDoc
deepdescend into child if set
optionsoption flags
Returns
0 if the operation succeeded, 1 if a node of unsupported (or not yet supported) type was given, -1 on API/internal errors.

◆ xmlDOMWrapFreeCtxt()

void xmlDOMWrapFreeCtxt ( xmlDOMWrapCtxt * ctxt)

Frees the DOM-wrapper context.

Parameters
ctxtthe DOM-wrapper context

◆ xmlDOMWrapNewCtxt()

xmlDOMWrapCtxt * xmlDOMWrapNewCtxt ( void )

Allocates and initializes a new DOM-wrapper context.

Returns
the xmlDOMWrapCtxt or NULL in case of an internal error.

◆ xmlDOMWrapReconcileNamespaces()

int xmlDOMWrapReconcileNamespaces ( xmlDOMWrapCtxt * ctxt,
xmlNode * elem,
int options )

Fix up namespaces.

Ensures that ns-references point to ns-decls hold on element-nodes. Ensures that the tree is namespace wellformed by creating additional ns-decls where needed. Note that, since prefixes of already existent ns-decls can be shadowed by this process, it could break QNames in attribute values or element content.

NOTE: This function was not intensively tested.

Parameters
ctxtDOM wrapper context, unused at the moment
elemthe element-node
optionsoption flags
Returns
0 if succeeded, -1 otherwise and on API/internal errors.

◆ xmlDOMWrapRemoveNode()

int xmlDOMWrapRemoveNode ( xmlDOMWrapCtxt * ctxt,
xmlDoc * doc,
xmlNode * node,
int options )

Unlinks the given node from its owner.

This will substitute ns-references to node->nsDef for ns-references to doc->oldNs, thus ensuring the removed branch to be autark wrt ns-references.

NOTE: This function was not intensively tested.

Parameters
ctxta DOM wrapper context
docthe doc
nodethe node to be removed.
optionsset of options, unused at the moment
Returns
0 on success, 1 if the node is not supported, -1 on API and internal errors.

◆ xmlElemDump()

void xmlElemDump ( FILE * f,
xmlDoc * doc,
xmlNode * cur )

Serialize an XML node to a FILE.

Uses the document's encoding. If the document has no encoding, uses ASCII without an encoding declaration.

Parameters
fthe FILE * for the output
docthe document
curthe current node

◆ xmlFirstElementChild()

xmlNode * xmlFirstElementChild ( xmlNode * parent)

Find the first child node which is an element.

Note that entity references are not expanded.

Parameters
parentthe parent node
Returns
the first element or NULL if parent has no children.

◆ xmlFreeDoc()

void xmlFreeDoc ( xmlDoc * cur)

Free a document including all children and associated DTDs.

Parameters
curpointer to the document

◆ xmlFreeDtd()

void xmlFreeDtd ( xmlDtd * cur)

Free a DTD structure.

Parameters
curthe DTD structure to free up

◆ xmlFreeNode()

void xmlFreeNode ( xmlNode * cur)

Free a node including all the children.

This doesn't unlink the node from the tree. Call xmlUnlinkNode first unless cur is a root node.

Parameters
curthe node

◆ xmlFreeNodeList()

void xmlFreeNodeList ( xmlNode * cur)

Free a node list including all children.

Parameters
curthe first node in the list

◆ xmlFreeNs()

void xmlFreeNs ( xmlNs * cur)

Free an xmlNs object.

Parameters
curthe namespace pointer

◆ xmlFreeNsList()

void xmlFreeNsList ( xmlNs * cur)

Free a list of xmlNs objects.

Parameters
curthe first namespace pointer

◆ xmlFreeProp()

void xmlFreeProp ( xmlAttr * cur)

Free an attribute including all children.

Parameters
curan attribute

◆ xmlFreePropList()

void xmlFreePropList ( xmlAttr * cur)

Free an attribute list including all children.

Parameters
curthe first attribute in the list

◆ xmlGetBufferAllocationScheme()

xmlBufferAllocationScheme xmlGetBufferAllocationScheme ( void )

Get the buffer allocation scheme.

Deprecated
Allocation schemes were removed.
Returns
the current allocation scheme

◆ xmlGetCompressMode()

int xmlGetCompressMode ( void )

Get the global compression level, ZLIB based.

Deprecated
Use xmlGetDocCompressMode
Returns
0 (uncompressed) to 9 (max compression)

◆ xmlGetDocCompressMode()

int xmlGetDocCompressMode ( const xmlDoc * doc)

Get the compression level of a document, ZLIB based.

Parameters
docthe document
Returns
0 (uncompressed) to 9 (max compression)

◆ xmlGetIntSubset()

xmlDtd * xmlGetIntSubset ( const xmlDoc * doc)

Get the internal subset of a document.

Parameters
docthe document pointer
Returns
a pointer to the DTD object or NULL if not found.

◆ xmlGetLastChild()

xmlNode * xmlGetLastChild ( const xmlNode * parent)

Find the last child of a node.

Parameters
parentthe parent node
Returns
the last child or NULL if parent has no children.

◆ xmlGetLineNo()

long xmlGetLineNo ( const xmlNode * node)

Get line number of node.

Try to work around the limitation of line numbers being stored as 16 bits ints. Requires xmlParserOption XML_PARSE_BIG_LINES to be set when parsing.

Parameters
nodevalid node
Returns
the line number if successful, -1 otherwise

◆ xmlGetNodePath()

xmlChar * xmlGetNodePath ( const xmlNode * node)

Build a structure based Path for the given node.

Parameters
nodea node
Returns
the new path or NULL in case of error. The caller must free the returned string

◆ xmlGetNoNsProp()

xmlChar * xmlGetNoNsProp ( const xmlNode * node,
const xmlChar * name )

Look up the value of an element's attribute.

Entities are substituted. The returned value must be freed by the caller.

This function looks in DTD attribute declarations for #FIXED or default declaration values.

This function is similar to xmlGetProp except it will accept only an attribute in no namespace.

NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue.

Parameters
nodethe element
namethe attribute name
Returns
the attribute value or NULL if not found or a memory allocation failed.

◆ xmlGetNsList()

xmlNs ** xmlGetNsList ( const xmlDoc * doc,
const xmlNode * node )

Find all in-scope namespaces of a node.

Use xmlGetNsListSafe for better error reporting.

Parameters
docthe document
nodethe current node
Returns
a NULL terminated array of namespace pointers that must be freed by the caller or NULL if no namespaces were found or a memory allocation failed.

◆ xmlGetNsListSafe()

int xmlGetNsListSafe ( const xmlDoc * doc,
const xmlNode * node,
xmlNs *** out )

Find all in-scope namespaces of a node.

out returns a NULL terminated array of namespace pointers that must be freed by the caller.

Since
2.13.0
Parameters
docthe document
nodethe current node
outthe returned namespace array
Returns
0 on success, 1 if no namespaces were found, -1 if a memory allocation failed.

◆ xmlGetNsProp()

xmlChar * xmlGetNsProp ( const xmlNode * node,
const xmlChar * name,
const xmlChar * nameSpace )

Look up the value of an element's attribute.

The attribute has to match the specified namespace. A namespace of NULL means that the attribute must have no namespace.

Entities are substituted. The returned value must be freed by the caller.

This function looks in DTD attribute declaration for #FIXED or default declaration values.

NOTE: This function doesn't allow to distinguish malloc failures from missing attributes. It's more robust to use xmlNodeGetAttrValue.

Parameters
nodethe element
namethe attribute name
nameSpacethe URI of the namespace
Returns
the attribute value or NULL if not found or a memory allocation failed.

◆ xmlGetProp()

xmlChar * xmlGetProp ( const xmlNode * node,
const xmlChar * name )

Look up the value of an element's attribute.

Entities are substituted. The returned value must be freed by the caller.

This function looks in DTD attribute declarations for #FIXED or default declaration values.

NOTE: This function is ignores namespaces. Use xmlGetNsProp or xmlGetNoNsProp for namespace aware processing.

NOTE: This function doesn't allow to distinguish malloc failures from missing attributes.

Parameters
nodethe element
namethe attribute name
Returns
the attribute value or NULL if not found or a memory allocation failed.

◆ xmlHasNsProp()

xmlAttr * xmlHasNsProp ( const xmlNode * node,
const xmlChar * name,
const xmlChar * nameSpace )

Search for an attribute of an element.

The attribute has to match the specified namespace. A namespace of NULL means that the attribute must have no namespace.

This function also looks in DTD attribute declaration for #FIXED or default declaration values.

Parameters
nodethe element
namethe attribute name
nameSpacethe URI of the namespace
Returns
the attribute or the attribute declaration or NULL if neither was found. Also returns NULL if a memory allocation failed making this function unreliable.

◆ xmlHasProp()

xmlAttr * xmlHasProp ( const xmlNode * node,
const xmlChar * name )

Search for an attribute of an element.

This function also looks in DTD attribute declaration for #FIXED or default declaration values.

Parameters
nodethe element
namethe attribute name
Returns
the attribute or the attribute declaration or NULL if neither was found. Also returns NULL if a memory allocation failed, making this function unreliable.

◆ xmlIsBlankNode()

int xmlIsBlankNode ( const xmlNode * node)

Checks whether this node is an empty or whitespace-only text node.

Parameters
nodethe node
Returns
1 if yes, 0 if no

◆ xmlIsXHTML()

int xmlIsXHTML ( const xmlChar * systemID,
const xmlChar * publicID )

Try to find if the document correspond to an XHTML DTD.

Parameters
systemIDthe system identifier
publicIDthe public identifier
Returns
1 if true, 0 if not and -1 in case of error

◆ xmlLastElementChild()

xmlNode * xmlLastElementChild ( xmlNode * parent)

Find the last child node which is an element.

Note that entity references are not expanded.

Parameters
parentthe parent node
Returns
the last element or NULL if parent has no children.

◆ xmlNewCDataBlock()

xmlNode * xmlNewCDataBlock ( xmlDoc * doc,
const xmlChar * content,
int len )

Create a CDATA section node.

Parameters
docthe target document (optional)
contentraw text content (optional)
lensize of text content
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNewCharRef()

xmlNode * xmlNewCharRef ( xmlDoc * doc,
const xmlChar * name )

Create an empty entity reference node.

This function is MISNAMED. It doesn't create a character reference but an entity reference.

This function doesn't attempt to look up the entity in doc.

Entity names like &entity; are handled as well.

Parameters
docthe target document (optional)
namethe entity name
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewChild()

xmlNode * xmlNewChild ( xmlNode * parent,
xmlNs * ns,
const xmlChar * name,
const xmlChar * content )

Create a new child element and append it to a parent element.

If ns is NULL, the newly created element inherits the namespace of the parent.

If provided, content is expected to be a valid XML attribute value possibly containing character and entity references. Text and entity reference node will be added to the child element, see xmlNewDocNode.

Parameters
parentthe parent node
nsa namespace (optional)
namethe name of the child
contenttext content with XML references (optional)
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewComment()

xmlNode * xmlNewComment ( const xmlChar * content)

Use of this function is DISCOURAGED in favor of xmlNewDocComment.

Create a comment node.

Parameters
contentthe comment content (optional)
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNewDoc()

xmlDoc * xmlNewDoc ( const xmlChar * version)

Creates a new XML document.

If version is NULL, "1.0" is used.

Parameters
versionXML version string like "1.0" (optional)
Returns
a new document or NULL if a memory allocation failed.

◆ xmlNewDocComment()

xmlNode * xmlNewDocComment ( xmlDoc * doc,
const xmlChar * content )

Create a comment node.

Parameters
docthe document
contentthe comment content
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNewDocFragment()

xmlNode * xmlNewDocFragment ( xmlDoc * doc)

Create a document fragment node.

Parameters
docthe target document (optional)
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNewDocNode()

xmlNode * xmlNewDocNode ( xmlDoc * doc,
xmlNs * ns,
const xmlChar * name,
const xmlChar * content )

Create an element node.

If provided, content is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. Only references are handled, nested elements, comments or PIs are not. See xmlNewDocRawNode for an alternative.

General notes on object creation:

Each node and all its children are associated with the same document. The document should be provided when creating nodes to avoid a performance penalty when adding the node to a document tree. Note that a document only owns nodes reachable from the root node. Unlinked subtrees must be freed manually.

Parameters
docthe target document
nsnamespace (optional)
namethe node name
contenttext content with XML references (optional)
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewDocNodeEatName()

xmlNode * xmlNewDocNodeEatName ( xmlDoc * doc,
xmlNs * ns,
xmlChar * name,
const xmlChar * content )

Create an element node.

Like xmlNewDocNode, but the name string will be used directly without making a copy. Takes ownership of name which will also be freed on error.

Parameters
docthe target document
nsnamespace (optional)
namethe node name
contenttext content with XML references (optional)
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewDocPI()

xmlNode * xmlNewDocPI ( xmlDoc * doc,
const xmlChar * name,
const xmlChar * content )

Create a processing instruction object.

Parameters
docthe target document (optional)
namethe processing instruction target
contentthe PI content (optional)
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewDocProp()

xmlAttr * xmlNewDocProp ( xmlDoc * doc,
const xmlChar * name,
const xmlChar * value )

Create an attribute node.

If provided, value is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. If you want to pass a raw string, see xmlNewProp.

Parameters
docthe target document (optional)
namethe name of the attribute
valueattribute value with XML references (optional)
Returns
a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewDocRawNode()

xmlNode * xmlNewDocRawNode ( xmlDoc * doc,
xmlNs * ns,
const xmlChar * name,
const xmlChar * content )

Create an element node.

If provided, value should be a raw, unescaped string.

Parameters
docthe target document
nsnamespace (optional)
namethe node name
contentraw text content (optional)
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewDocText()

xmlNode * xmlNewDocText ( const xmlDoc * doc,
const xmlChar * content )

Create a new text node.

Parameters
docthe target document
contentraw text content (optional)
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNewDocTextLen()

xmlNode * xmlNewDocTextLen ( xmlDoc * doc,
const xmlChar * content,
int len )

Create a new text node.

Parameters
docthe target document
contentraw text content (optional)
lensize of text content
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNewDtd()

xmlDtd * xmlNewDtd ( xmlDoc * doc,
const xmlChar * name,
const xmlChar * publicId,
const xmlChar * systemId )

Create a DTD node.

If a document is provided, it is an error if it already has an external subset. If the document has no external subset, it will be set to the created DTD.

To create an internal subset, use xmlCreateIntSubset.

Parameters
docthe document pointer (optional)
namethe DTD name (optional)
publicIdpublic identifier of the DTD (optional)
systemIdsystem identifier (URL) of the DTD (optional)
Returns
a pointer to the new DTD object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewNode()

xmlNode * xmlNewNode ( xmlNs * ns,
const xmlChar * name )

Create an element node.

Use of this function is DISCOURAGED in favor of xmlNewDocNode.

Parameters
nsnamespace (optional)
namethe node name
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewNodeEatName()

xmlNode * xmlNewNodeEatName ( xmlNs * ns,
xmlChar * name )

Create an element node.

Use of this function is DISCOURAGED in favor of xmlNewDocNodeEatName.

Like xmlNewNode, but the name string will be used directly without making a copy. Takes ownership of name which will also be freed on error.

Parameters
nsnamespace (optional)
namethe node name
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewNs()

xmlNs * xmlNewNs ( xmlNode * node,
const xmlChar * href,
const xmlChar * prefix )

Create a new namespace.

For a default namespace, prefix should be NULL. The namespace URI in href is not checked. You should make sure to pass a valid URI.

If node is provided, it must be an element node. The namespace will be appended to the node's namespace declarations. It is an error if the node already has a definition for the prefix or default namespace.

Parameters
nodethe element carrying the namespace (optional)
hrefthe URI associated
prefixthe prefix for the namespace (optional)
Returns
a new namespace pointer or NULL if arguments are invalid, the prefix is already in use or a memory allocation failed.

◆ xmlNewNsProp()

xmlAttr * xmlNewNsProp ( xmlNode * node,
xmlNs * ns,
const xmlChar * name,
const xmlChar * value )

Create an attribute node.

If provided, value should be a raw, unescaped string.

If node is provided, the created attribute will be appended without checking for duplicate names. It is an error if node is not an element.

Parameters
nodethe parent node (optional)
nsthe namespace (optional)
namethe local name of the attribute
valuethe value of the attribute (optional)
Returns
a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewNsPropEatName()

xmlAttr * xmlNewNsPropEatName ( xmlNode * node,
xmlNs * ns,
xmlChar * name,
const xmlChar * value )

Create an attribute node.

Like xmlNewNsProp, but the name string will be used directly without making a copy. Takes ownership of name which will also be freed on error.

Parameters
nodethe parent node (optional)
nsthe namespace (optional)
namethe local name of the attribute
valuethe value of the attribute (optional)
Returns
a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewPI()

xmlNode * xmlNewPI ( const xmlChar * name,
const xmlChar * content )

Create a processing instruction node.

Use of this function is DISCOURAGED in favor of xmlNewDocPI.

Parameters
namethe processing instruction target
contentthe PI content (optional)
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewProp()

xmlAttr * xmlNewProp ( xmlNode * node,
const xmlChar * name,
const xmlChar * value )

Create an attribute node.

If provided, value should be a raw, unescaped string.

If node is provided, the created attribute will be appended without checking for duplicate names. It is an error if node is not an element.

Parameters
nodethe parent node (optional)
namethe name of the attribute
valuethe value of the attribute (optional)
Returns
a pointer to the attribute or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewReference()

xmlNode * xmlNewReference ( const xmlDoc * doc,
const xmlChar * name )

Create a new entity reference node, linking the result with the entity in doc if found.

Entity names like &entity; are handled as well.

Parameters
docthe target document (optional)
namethe entity name
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewText()

xmlNode * xmlNewText ( const xmlChar * content)

Create a text node.

Use of this function is DISCOURAGED in favor of xmlNewDocText.

Parameters
contentraw text content (optional)
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNewTextChild()

xmlNode * xmlNewTextChild ( xmlNode * parent,
xmlNs * ns,
const xmlChar * name,
const xmlChar * content )

Create a new child element and append it to a parent element.

If ns is NULL, the newly created element inherits the namespace of the parent.

If content is provided, a text node will be added to the child element, see xmlNewDocRawNode.

Parameters
parentthe parent node
nsa namespace (optional)
namethe name of the child
contentraw text content of the child (optional)
Returns
a pointer to the new node object or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNewTextLen()

xmlNode * xmlNewTextLen ( const xmlChar * content,
int len )

Create a new text node.

Use of this function is DISCOURAGED in favor of xmlNewDocTextLen.

Parameters
contentraw text content (optional)
lensize of text content
Returns
a pointer to the new node object or NULL if a memory allocation failed.

◆ xmlNextElementSibling()

xmlNode * xmlNextElementSibling ( xmlNode * node)

Find the closest following sibling which is a element.

Note that entity references are not expanded.

Parameters
nodethe current node
Returns
the sibling or NULL if no sibling was found.

◆ xmlNodeAddContent()

int xmlNodeAddContent ( xmlNode * cur,
const xmlChar * content )

Append the extra substring to the node content.

NOTE: In contrast to xmlNodeSetContent, content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.

This doesn't work on attributes before version 2.15.

Parameters
curthe node being modified
contentextra content
Returns
0 on success, 1 on error, -1 if a memory allocation failed.

◆ xmlNodeAddContentLen()

int xmlNodeAddContentLen ( xmlNode * cur,
const xmlChar * content,
int len )

Append the extra substring to the node content.

NOTE: In contrast to xmlNodeSetContentLen, content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.

This doesn't work on attributes before version 2.15.

Parameters
curthe node being modified
contentextra content
lenthe size of content
Returns
0 on success, 1 on error, -1 if a memory allocation failed.

◆ xmlNodeBufGetContent()

int xmlNodeBufGetContent ( xmlBuffer * buffer,
const xmlNode * cur )

Append the string value of a node to buffer.

For text nodes, the string value is the text content. Otherwise, the string value is the concatenation of the string values of the node's descendants.

Entity references are substituted.

Parameters
buffera buffer
curthe node being read
Returns
0 in case of success and -1 in case of error.

◆ xmlNodeDump()

int xmlNodeDump ( xmlBuffer * buf,
xmlDoc * doc,
xmlNode * cur,
int level,
int format )

Serialize an XML node to an xmlBuffer.

Uses the document's encoding. If the document has no encoding, uses ASCII without an encoding declaration.

Note that format only works if the document was parsed with XML_PARSE_NOBLANKS.

Since this is using xmlBuffer structures it is limited to 2GB and somewhat deprecated, use xmlNodeDumpOutput instead.

Parameters
bufthe XML buffer output
docthe document
curthe current node
levelthe initial indenting level
formatis formatting allowed
Returns
the number of bytes written to the buffer or -1 in case of error

◆ xmlNodeDumpOutput()

void xmlNodeDumpOutput ( xmlOutputBuffer * buf,
xmlDoc * doc,
xmlNode * cur,
int level,
int format,
const char * encoding )

Serialize an XML node to an output buffer.

If encoding is NULL, uses the document's encoding. If the document has no encoding, serializes as ASCII without an encoding declaration.

Note that format only works if the document was parsed with XML_PARSE_NOBLANKS.

Parameters
bufthe XML buffer output
docthe document
curthe current node
levelthe imbrication level for indenting
formatis formatting allowed
encodingan optional encoding string

◆ xmlNodeGetAttrValue()

int xmlNodeGetAttrValue ( const xmlNode * node,
const xmlChar * name,
const xmlChar * nsUri,
xmlChar ** out )

Look up the value of an element's attribute.

The attribute has to match the specified namespace. A namespace of NULL means that the attribute must have no namespace.

Entities are substituted. The returned value must be freed by the caller.

Since
2.13.0
Parameters
nodethe element
namethe attribute name
nsUrithe URI of the namespace
outthe returned string
Returns
0 on success, 1 if no attribute was found, -1 if a memory allocation failed.

◆ xmlNodeGetBase()

xmlChar * xmlNodeGetBase ( const xmlDoc * doc,
const xmlNode * cur )

See xmlNodeGetBaseSafe.

This function doesn't allow to distinguish memory allocation failures from a non-existing base.

Parameters
docthe document the node pertains to
curthe node being checked
Returns
a pointer to the base URL, or NULL if not found It's up to the caller to free the memory with xmlFree.

◆ xmlNodeGetBaseSafe()

int xmlNodeGetBaseSafe ( const xmlDoc * doc,
const xmlNode * cur,
xmlChar ** baseOut )

Searches for the base URI.

The code should work on both XML and HTML document even if base mechanisms are completely different. It returns the base as defined in RFC 2396 sections "5.1.1. Base URI within Document Content" and "5.1.2. Base URI from the Encapsulating Entity". However it does not return the document base (5.1.3), use doc->URL in this case.

Since
2.13.0
Parameters
docthe document the node pertains to
curthe node being checked
baseOutpointer to base
Returns
0 in case of success, 1 if a URI or argument is invalid, -1 if a memory allocation failed.

◆ xmlNodeGetContent()

xmlChar * xmlNodeGetContent ( const xmlNode * cur)

Returns the string value of a node.

For text nodes, the string value is the text content. Otherwise, the string value is the concatenation of the string values of the node's descendants.

Entity references are substituted.

It's up to the caller to free the result with xmlFree.

Parameters
curthe node being read
Returns
a new string or NULL if arguments are invalid or a memory allocation failed.

◆ xmlNodeGetLang()

xmlChar * xmlNodeGetLang ( const xmlNode * cur)

Find the xml:lang of a node.

Look up the value of the xml:lang attribute or the one carried by the nearest ancestor.

Parameters
curthe node being checked
Returns
a pointer to the lang value, or NULL if not found It's up to the caller to free the memory with xmlFree.

◆ xmlNodeGetSpacePreserve()

int xmlNodeGetSpacePreserve ( const xmlNode * cur)

Find the xml:space of a node.

Look up the value of the xml:space attribute or the one carried by the nearest ancestor.

Parameters
curthe node being checked
Returns
-1 if xml:space is not inherited, 0 if "default", 1 if "preserve"

◆ xmlNodeIsText()

int xmlNodeIsText ( const xmlNode * node)

Check whether the node is a text node.

Parameters
nodethe node
Returns
1 if yes, 0 if no

◆ xmlNodeListGetRawString()

xmlChar * xmlNodeListGetRawString ( const xmlDoc * doc,
const xmlNode * list,
int inLine )

Serializes attribute children (text and entity reference nodes) into a string.

If inLine is true, entity references will be substituted. Otherwise, entity references will be kept and special characters like & will be escaped. See xmlEncodeSpecialChars for details.

Parameters
doca document (unused)
lista node list of attribute children
inLinewhether entity references are substituted
Returns
a string or NULL if a memory allocation failed.

◆ xmlNodeListGetString()

xmlChar * xmlNodeListGetString ( xmlDoc * doc,
const xmlNode * list,
int inLine )

Serializes attribute children (text and entity reference nodes) into a string.

If inLine is true, entity references will be substituted. Otherwise, entity references will be kept and special characters like & as well as non-ASCII chars will be escaped. See xmlEncodeEntitiesReentrant for details. If list is the child of an attribute, escaping rules apply are adjusted.

See xmlNodeListGetRawString for an alternative option.

Parameters
doca document (optional)
lista node list of attribute children
inLinewhether entity references are substituted
Returns
a string or NULL if a memory allocation failed.

◆ xmlNodeSetBase()

int xmlNodeSetBase ( xmlNode * cur,
const xmlChar * uri )

Set (or reset) the base URI of a node, i.e.

the value of the xml:base attribute.

Parameters
curthe node being changed
urithe new base URI
Returns
0 on success, -1 on error.

◆ xmlNodeSetContent()

int xmlNodeSetContent ( xmlNode * cur,
const xmlChar * content )

Replace the text content of a node.

Sets the raw text content of text, CDATA, comment or PI nodes.

For element and attribute nodes, removes all children and replaces them by parsing content which is expected to be a valid XML attribute value possibly containing character and entity references. Syntax errors and references to undeclared entities are ignored silently. Unfortunately, there isn't an API to pass raw content directly. An inefficient work-around is to escape the content with xmlEncodeSpecialChars before passing it. A better trick is clearing the old content with xmlNodeSetContent(node, NULL) first and then calling xmlNodeAddContent(node, content). Unlike this function, xmlNodeAddContent accepts raw text.

Parameters
curthe node being modified
contentthe new value of the content
Returns
0 on success, 1 on error, -1 if a memory allocation failed.

◆ xmlNodeSetContentLen()

int xmlNodeSetContentLen ( xmlNode * cur,
const xmlChar * content,
int len )

See xmlNodeSetContent.

Parameters
curthe node being modified
contentthe new value of the content
lenthe size of content
Returns
0 on success, 1 on error, -1 if a memory allocation failed.

◆ xmlNodeSetLang()

int xmlNodeSetLang ( xmlNode * cur,
const xmlChar * lang )

Set the xml:lang attribute of a node.

Parameters
curthe node being changed
langthe language description
Returns
0 on success, 1 if arguments are invalid, -1 if a memory allocation failed.

◆ xmlNodeSetName()

void xmlNodeSetName ( xmlNode * cur,
const xmlChar * name )

Set (or reset) the name of a node.

Parameters
curthe node being changed
namethe new tag name

◆ xmlNodeSetSpacePreserve()

int xmlNodeSetSpacePreserve ( xmlNode * cur,
int val )

Set the xml:space attribute of a node.

Parameters
curthe node being changed
valthe xml:space value ("0": default, 1: "preserve")
Returns
0 on success, 1 if arguments are invalid, -1 if a memory allocation failed.

◆ xmlPreviousElementSibling()

xmlNode * xmlPreviousElementSibling ( xmlNode * node)

Find the closest preceding sibling which is a element.

Note that entity references are not expanded.

Parameters
nodethe current node
Returns
the sibling or NULL if no sibling was found.

◆ xmlReconciliateNs()

int xmlReconciliateNs ( xmlDoc * doc,
xmlNode * tree )

This function checks that all the namespaces declared within the given tree are properly declared.

This is needed for example after copy or cut and then paste operations. The subtree may still hold pointers to namespace declarations outside the subtree or invalid/masked. As much as possible the function tries to reuse the existing namespaces found in the new environment. If not possible the new namespaces are redeclared on tree at the top of the given subtree.

Parameters
docthe document
treea node defining the subtree to reconciliate
Returns
0 on success or -1 in case of error.

◆ xmlRegisterNodeDefault()

xmlRegisterNodeFunc xmlRegisterNodeDefault ( xmlRegisterNodeFunc func)

Registers a callback for node creation.

Deprecated
don't use
Parameters
funcfunction pointer to the new RegisterNodeFunc
Returns
the old value of the registration function

◆ xmlRemoveProp()

int xmlRemoveProp ( xmlAttr * cur)

Unlink and free an attribute including all children.

Note this doesn't work for namespace declarations.

The attribute must have a non-NULL parent pointer.

Parameters
curan attribute
Returns
0 on success or -1 if the attribute was not found or arguments are invalid.

◆ xmlReplaceNode()

xmlNode * xmlReplaceNode ( xmlNode * old,
xmlNode * cur )

Unlink the old node.

If cur is provided, it is unlinked and inserted in place of old.

It is an error if old has no parent.

Unlike xmlAddChild, this function doesn't merge text nodes or delete duplicate attributes.

See the notes in xmlAddChild.

Parameters
oldthe old node
curthe node (optional)
Returns
old or NULL if arguments are invalid or a memory allocation failed.

◆ xmlSaveFile()

int xmlSaveFile ( const char * filename,
xmlDoc * cur )

Same as xmlSaveFormatFileEnc with encoding set to NULL and format set to 0.

Parameters
filenamethe filename (or URL)
curthe document
Returns
the number of bytes written or -1 in case of failure.

◆ xmlSaveFileEnc()

int xmlSaveFileEnc ( const char * filename,
xmlDoc * cur,
const char * encoding )

Same as xmlSaveFormatFileEnc with format set to 0.

Parameters
filenamethe filename (or URL)
curthe document
encodingthe name of an encoding (or NULL)
Returns
the number of bytes written or -1 in case of failure.

◆ xmlSaveFileTo()

int xmlSaveFileTo ( xmlOutputBuffer * buf,
xmlDoc * cur,
const char * encoding )

Same as xmlSaveFormatFileTo with format set to 0.

WARNING: This calls xmlOutputBufferClose and frees buf.

Parameters
bufan output I/O buffer
curthe document
encodingthe encoding if any assuming the I/O layer handles the transcoding
Returns
the number of bytes written or -1 in case of failure.

◆ xmlSaveFormatFile()

int xmlSaveFormatFile ( const char * filename,
xmlDoc * cur,
int format )

Same as xmlSaveFormatFileEnc with encoding set to NULL.

Parameters
filenamethe filename (or URL)
curthe document
formatshould formatting spaces been added
Returns
the number of bytes written or -1 in case of failure.

◆ xmlSaveFormatFileEnc()

int xmlSaveFormatFileEnc ( const char * filename,
xmlDoc * cur,
const char * encoding,
int format )

Serialize an XML document to a file using the given encoding.

If filename is "-", stdout is used. This is potentially insecure and might be changed in a future version.

If encoding is NULL, uses the document's encoding. If the document has no encoding, serializes as ASCII without an encoding declaration.

Note that format only works if the document was parsed with XML_PARSE_NOBLANKS.

Parameters
filenamethe filename or URL to output
curthe document being saved
encodingthe name of the encoding to use or NULL.
formatshould formatting spaces be added.
Returns
the number of bytes written or -1 in case of error.

◆ xmlSaveFormatFileTo()

int xmlSaveFormatFileTo ( xmlOutputBuffer * buf,
xmlDoc * cur,
const char * encoding,
int format )

Serialize an XML document to an output buffer.

If the output buffer already uses a (non-default) encoding, encoding is ignored. If the output buffer has no encoding and encoding is NULL, uses the document's encoding or ASCII without an encoding declaration.

Note that format only works if the document was parsed with XML_PARSE_NOBLANKS.

WARNING: This calls xmlOutputBufferClose and frees buf.

Parameters
bufan output I/O buffer
curthe document
encodingthe encoding if any assuming the I/O layer handles the transcoding
formatshould formatting spaces been added
Returns
the number of bytes written or -1 in case of failure.

◆ xmlSearchNs()

xmlNs * xmlSearchNs ( xmlDoc * doc,
xmlNode * node,
const xmlChar * nameSpace )

Search for a namespace with prefix in scope of node.

Recurse on the parents until it finds the defined namespace or return NULL otherwise.

If nameSpace is NULL, the default namespace is looked up.

Namespace search doesn't cross entity boundaries.

Parameters
docthe document
nodethe current node
nameSpacethe namespace prefix
Returns
the namespace pointer or NULL if no namespace was found or a memory allocation failed. Allocations can only fail if the xml namespace is queried.

◆ xmlSearchNsByHref()

xmlNs * xmlSearchNsByHref ( xmlDoc * doc,
xmlNode * node,
const xmlChar * href )

Search for a namespace matching URI in scope of node.

Parameters
docthe document
nodethe current node
hrefthe namespace value
Returns
the namespace pointer or NULL if no namespace was found or a memory allocation failed. Allocations can only fail if the xml namespace is queried.

◆ xmlSetBufferAllocationScheme()

void xmlSetBufferAllocationScheme ( xmlBufferAllocationScheme scheme)

Set the buffer allocation scheme.

Deprecated
No-op, allocation schemes were removed.
Parameters
schemeallocation method to use

◆ xmlSetCompressMode()

void xmlSetCompressMode ( int mode)

Set the global compression level, ZLIB based.

Deprecated
Use xmlSetDocCompressMode

Correct values: 0 (uncompressed) to 9 (max compression)

Parameters
modethe compression ratio

◆ xmlSetDocCompressMode()

void xmlSetDocCompressMode ( xmlDoc * doc,
int mode )

Set the compression level of a document, ZLIB based.

Correct values: 0 (uncompressed) to 9 (max compression)

Parameters
docthe document
modethe compression ratio

◆ xmlSetListDoc()

int xmlSetListDoc ( xmlNode * list,
xmlDoc * doc )

Associate all subtrees in list with a new document.

Internal function, see xmlSetTreeDoc.

Parameters
lista node list
docnew document
Returns
0 on success. If a memory allocation fails, returns -1. All subtrees will be updated on failure but some strings may be lost.

◆ xmlSetNs()

void xmlSetNs ( xmlNode * node,
xmlNs * ns )

Set the namespace of an element or attribute node.

Passing a NULL namespace unsets the namespace.

Parameters
nodea node in the document
nsa namespace pointer (optional)

◆ xmlSetNsProp()

xmlAttr * xmlSetNsProp ( xmlNode * node,
xmlNs * ns,
const xmlChar * name,
const xmlChar * value )

Set (or reset) an element's attribute.

The namespace must be in scope.

Parameters
nodethe node
nsthe namespace definition
namethe attribute name
valuethe attribute value
Returns
the attribute pointer.

◆ xmlSetProp()

xmlAttr * xmlSetProp ( xmlNode * node,
const xmlChar * name,
const xmlChar * value )

Set (or reset) an element's attribute.

If name has a prefix, the corresponding namespace will be used. It is an error if there's no such binding for the prefix in scope.

Parameters
nodethe node
namethe attribute name (a QName)
valuethe attribute value
Returns
the attribute pointer.

◆ xmlSetTreeDoc()

int xmlSetTreeDoc ( xmlNode * tree,
xmlDoc * doc )

Associate all nodes in a tree with a new document.

This is an internal function which shouldn't be used. It is invoked by functions like xmlAddChild, xmlAddSibling or xmlReplaceNode. tree must be the root node of an unlinked subtree.

Also copy strings from the old document's dictionary and remove ID attributes from the old ID table.

Parameters
treeroot of a subtree
docnew document
Returns
0 on success. If a memory allocation fails, returns -1. The whole tree will be updated on failure but some strings may be lost.

◆ xmlSplitQName2()

xmlChar * xmlSplitQName2 ( const xmlChar * name,
xmlChar ** prefix )

Parse an XML qualified name.

Deprecated
This function doesn't report malloc failures.
[NS 5] QName ::= (Prefix ':')? LocalPart

[NS 6] Prefix ::= NCName

[NS 7] LocalPart ::= NCName
Parameters
namethe full QName
prefixa xmlChar **
Returns
NULL if the name doesn't have a prefix. Otherwise, returns the local part, and prefix is updated to get the Prefix. Both the return value and the prefix must be freed by the caller.

◆ xmlSplitQName3()

const xmlChar * xmlSplitQName3 ( const xmlChar * name,
int * len )

Parse an XML qualified name.

Parameters
namethe full QName
lenan int *
Returns
NULL if it is not a Qualified Name, otherwise, update len with the length in byte of the prefix and return a pointer to the start of the name without the prefix

◆ xmlStringGetNodeList()

xmlNode * xmlStringGetNodeList ( const xmlDoc * doc,
const xmlChar * value )

Parse an attribute value and build a node list with text and entity reference nodes.

The resulting nodes will be associated with the document if provided. The document is also used to look up entities.

Deprecated
Internal function, don't use.

The input is not validated. Syntax errors or references to undeclared entities will be ignored silently with unspecified results.

Parameters
doca document (optional)
valuean attribute value
Returns
a pointer to the first child or NULL if the value if empty or a memory allocation failed.

◆ xmlStringLenGetNodeList()

xmlNode * xmlStringLenGetNodeList ( const xmlDoc * doc,
const xmlChar * value,
int len )

See xmlStringGetNodeList.

Deprecated
Internal function, don't use.
Parameters
doca document (optional)
valuean attribute value
lenmaximum length of the attribute value
Returns
a pointer to the first child or NULL if the value if empty or a memory allocation failed.

◆ xmlTextConcat()

int xmlTextConcat ( xmlNode * node,
const xmlChar * content,
int len )

Concat the given string at the end of the existing node content.

If len is -1, the string length will be calculated.

Parameters
nodethe node
contentthe content
lencontent length
Returns
-1 in case of error, 0 otherwise

◆ xmlTextMerge()

xmlNode * xmlTextMerge ( xmlNode * first,
xmlNode * second )

Merge the second text node into the first.

If first is NULL, second is returned. Otherwise, the second node is unlinked and freed.

Parameters
firstthe first text node
secondthe second text node being merged
Returns
the first text node augmented or NULL in case of error.

◆ xmlThrDefDeregisterNodeDefault()

xmlDeregisterNodeFunc xmlThrDefDeregisterNodeDefault ( xmlDeregisterNodeFunc func)

Set per-thread default value.

Deprecated
This feature will be removed.
Parameters
funcnew value
Returns
the old value

◆ xmlThrDefRegisterNodeDefault()

xmlRegisterNodeFunc xmlThrDefRegisterNodeDefault ( xmlRegisterNodeFunc func)

Set per-thread default value.

Deprecated
This feature will be removed.
Parameters
funcnew value
Returns
the old value

◆ xmlUnlinkNode()

void xmlUnlinkNode ( xmlNode * cur)

Unlink a node from its tree.

The node is not freed. Unless it is reinserted, it must be managed manually and freed eventually by calling xmlFreeNode.

Parameters
curthe node

◆ xmlUnsetNsProp()

int xmlUnsetNsProp ( xmlNode * node,
xmlNs * ns,
const xmlChar * name )

Remove an attribute of an element.

Parameters
nodethe element
nsthe namespace definition
namethe attribute name
Returns
0 if successful, -1 if not found

◆ xmlUnsetProp()

int xmlUnsetProp ( xmlNode * node,
const xmlChar * name )

Remove an attribute of an element.

This handles only attributes in no namespace.

Parameters
nodethe element
namethe attribute name
Returns
0 if successful, -1 if not found

◆ xmlValidateName()

int xmlValidateName ( const xmlChar * value,
int space )

Check that a value conforms to the lexical space of Name.

Parameters
valuethe value to check
spaceallow spaces in front and end of the string
Returns
0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlValidateNCName()

int xmlValidateNCName ( const xmlChar * value,
int space )

Check that a value conforms to the lexical space of NCName.

Parameters
valuethe value to check
spaceallow spaces in front and end of the string
Returns
0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlValidateNMToken()

int xmlValidateNMToken ( const xmlChar * value,
int space )

Check that a value conforms to the lexical space of NMToken.

Parameters
valuethe value to check
spaceallow spaces in front and end of the string
Returns
0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlValidateQName()

int xmlValidateQName ( const xmlChar * value,
int space )

Check that a value conforms to the lexical space of QName.

Parameters
valuethe value to check
spaceallow spaces in front and end of the string
Returns
0 if this validates, a positive error code number otherwise and -1 in case of internal or API error.