Gnome XML Library Reference Manual |
---|
tree —
struct xmlParserInputBuffer; typedef xmlParserInputBufferPtr; struct xmlOutputBuffer; typedef xmlOutputBufferPtr; struct xmlParserInput; typedef xmlParserInputPtr; struct xmlParserCtxt; typedef xmlParserCtxtPtr; struct xmlSAXLocator; typedef xmlSAXLocatorPtr; struct xmlSAXHandler; typedef xmlSAXHandlerPtr; struct xmlEntity; typedef xmlEntityPtr; #define BASE_BUFFER_SIZE #define XML_XML_NAMESPACE enum xmlElementType; typedef xmlChar; #define BAD_CAST struct xmlNotation; typedef xmlNotationPtr; enum xmlAttributeType; enum xmlAttributeDefault; struct xmlEnumeration; typedef xmlEnumerationPtr; struct xmlAttribute; typedef xmlAttributePtr; enum xmlElementContentType; enum xmlElementContentOccur; struct xmlElementContent; typedef xmlElementContentPtr; enum xmlElementTypeVal; struct xmlElement; typedef xmlElementPtr; #define XML_LOCAL_NAMESPACE typedef xmlNsType; struct xmlNs; typedef xmlNsPtr; struct xmlDtd; typedef xmlDtdPtr; struct xmlAttr; typedef xmlAttrPtr; struct xmlID; typedef xmlIDPtr; struct xmlRef; typedef xmlRefPtr; enum xmlBufferAllocationScheme; struct xmlBuffer; typedef xmlBufferPtr; struct xmlNode; typedef xmlNodePtr; #define XML_GET_CONTENT (n) #define XML_GET_LINE (n) struct xmlDoc; typedef xmlDocPtr; #define xmlChildrenNode #define xmlRootNode int xmlValidateNCName (const xmlChar *value, int space); int xmlValidateQName (const xmlChar *value, int space); int xmlValidateName (const xmlChar *value, int space); int xmlValidateNMToken (const xmlChar *value, int space); xmlChar* xmlBuildQName (const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len); xmlChar* xmlSplitQName2 (const xmlChar *name, xmlChar **prefix); void xmlSetBufferAllocationScheme (xmlBufferAllocationScheme scheme); xmlBufferAllocationScheme xmlGetBufferAllocationScheme (void); xmlBufferPtr xmlBufferCreate (void); xmlBufferPtr xmlBufferCreateSize (size_t size); int xmlBufferResize (xmlBufferPtr buf, unsigned int size); void xmlBufferFree (xmlBufferPtr buf); int xmlBufferDump (FILE *file, xmlBufferPtr buf); void xmlBufferAdd (xmlBufferPtr buf, const xmlChar *str, int len); void xmlBufferAddHead (xmlBufferPtr buf, const xmlChar *str, int len); void xmlBufferCat (xmlBufferPtr buf, const xmlChar *str); void xmlBufferCCat (xmlBufferPtr buf, const char *str); int xmlBufferShrink (xmlBufferPtr buf, unsigned int len); int xmlBufferGrow (xmlBufferPtr buf, unsigned int len); void xmlBufferEmpty (xmlBufferPtr buf); const xmlChar* xmlBufferContent (const xmlBufferPtr buf); void xmlBufferSetAllocationScheme (xmlBufferPtr buf, xmlBufferAllocationScheme scheme); int xmlBufferLength (const xmlBufferPtr buf); xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); xmlDtdPtr xmlNewDtd (xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc); void xmlFreeDtd (xmlDtdPtr cur); xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc, const xmlChar *href, const xmlChar *prefix); xmlNsPtr xmlNewNs (xmlNodePtr node, const xmlChar *href, const xmlChar *prefix); void xmlFreeNs (xmlNsPtr cur); void xmlFreeNsList (xmlNsPtr cur); xmlDocPtr xmlNewDoc (const xmlChar *version); void xmlFreeDoc (xmlDocPtr cur); xmlAttrPtr xmlNewDocProp (xmlDocPtr doc, const xmlChar *name, const xmlChar *value); xmlAttrPtr xmlNewProp (xmlNodePtr node, const xmlChar *name, const xmlChar *value); xmlAttrPtr xmlNewNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value); xmlAttrPtr xmlNewNsPropEatName (xmlNodePtr node, xmlNsPtr ns, xmlChar *name, const xmlChar *value); void xmlFreePropList (xmlAttrPtr cur); void xmlFreeProp (xmlAttrPtr cur); xmlAttrPtr xmlCopyProp (xmlNodePtr target, xmlAttrPtr cur); xmlAttrPtr xmlCopyPropList (xmlNodePtr target, xmlAttrPtr cur); xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd); xmlDocPtr xmlCopyDoc (xmlDocPtr doc, int recursive); xmlNodePtr xmlNewDocNode (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); xmlNodePtr xmlNewDocNodeEatName (xmlDocPtr doc, xmlNsPtr ns, xmlChar *name, const xmlChar *content); xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); xmlNodePtr xmlNewNode (xmlNsPtr ns, const xmlChar *name); xmlNodePtr xmlNewNodeEatName (xmlNsPtr ns, xmlChar *name); xmlNodePtr xmlNewChild (xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); xmlNodePtr xmlNewTextChild (xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); xmlNodePtr xmlNewDocText (xmlDocPtr doc, const xmlChar *content); xmlNodePtr xmlNewText (const xmlChar *content); xmlNodePtr xmlNewPI (const xmlChar *name, const xmlChar *content); xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc, const xmlChar *content, int len); xmlNodePtr xmlNewTextLen (const xmlChar *content, int len); xmlNodePtr xmlNewDocComment (xmlDocPtr doc, const xmlChar *content); xmlNodePtr xmlNewComment (const xmlChar *content); xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc, const xmlChar *content, int len); xmlNodePtr xmlNewCharRef (xmlDocPtr doc, const xmlChar *name); xmlNodePtr xmlNewReference (xmlDocPtr doc, const xmlChar *name); xmlNodePtr xmlCopyNode (const xmlNodePtr node, int recursive); xmlNodePtr xmlDocCopyNode (const xmlNodePtr node, xmlDocPtr doc, int recursive); xmlNodePtr xmlCopyNodeList (const xmlNodePtr node); xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);long xmlGetLineNo (xmlNodePtr node); xmlChar* xmlGetNodePath (xmlNodePtr node); xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc); xmlNodePtr xmlGetLastChild (xmlNodePtr parent); int xmlNodeIsText (xmlNodePtr node); int xmlIsBlankNode (xmlNodePtr node); xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc, xmlNodePtr root); void xmlNodeSetName (xmlNodePtr cur, const xmlChar *name); xmlNodePtr xmlAddChild (xmlNodePtr parent, xmlNodePtr cur); xmlNodePtr xmlAddChildList (xmlNodePtr parent, xmlNodePtr cur); xmlNodePtr xmlReplaceNode (xmlNodePtr old, xmlNodePtr cur); xmlNodePtr xmlAddSibling (xmlNodePtr cur, xmlNodePtr elem); xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur, xmlNodePtr elem); xmlNodePtr xmlAddNextSibling (xmlNodePtr cur, xmlNodePtr elem); void xmlUnlinkNode (xmlNodePtr cur); xmlNodePtr xmlTextMerge (xmlNodePtr first, xmlNodePtr second); int xmlTextConcat (xmlNodePtr node, const xmlChar *content, int len); void xmlFreeNodeList (xmlNodePtr cur); void xmlFreeNode (xmlNodePtr cur); void xmlSetTreeDoc (xmlNodePtr tree, xmlDocPtr doc); void xmlSetListDoc (xmlNodePtr list, xmlDocPtr doc); xmlNsPtr xmlSearchNs (xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace); xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc, xmlNodePtr node, const xmlChar *href); xmlNsPtr* xmlGetNsList (xmlDocPtr doc, xmlNodePtr node); void xmlSetNs (xmlNodePtr node, xmlNsPtr ns); xmlNsPtr xmlCopyNamespace (xmlNsPtr cur); xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur); xmlAttrPtr xmlSetProp (xmlNodePtr node, const xmlChar *name, const xmlChar *value); xmlChar* xmlGetProp (xmlNodePtr node, const xmlChar *name); xmlChar* xmlGetNoNsProp (xmlNodePtr node, const xmlChar *name); xmlAttrPtr xmlHasProp (xmlNodePtr node, const xmlChar *name); xmlAttrPtr xmlHasNsProp (xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace); xmlAttrPtr xmlSetNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value); xmlChar* xmlGetNsProp (xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace); xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc, const xmlChar *value); xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc, const xmlChar *value, int len); xmlChar* xmlNodeListGetString (xmlDocPtr doc, xmlNodePtr list, int inLine); xmlChar* xmlNodeListGetRawString (xmlDocPtr doc, xmlNodePtr list, int inLine); void xmlNodeSetContent (xmlNodePtr cur, const xmlChar *content); void xmlNodeSetContentLen (xmlNodePtr cur, const xmlChar *content, int len); void xmlNodeAddContent (xmlNodePtr cur, const xmlChar *content); void xmlNodeAddContentLen (xmlNodePtr cur, const xmlChar *content, int len); xmlChar* xmlNodeGetContent (xmlNodePtr cur); xmlChar* xmlNodeGetLang (xmlNodePtr cur); void xmlNodeSetLang (xmlNodePtr cur, const xmlChar *lang); int xmlNodeGetSpacePreserve (xmlNodePtr cur); void xmlNodeSetSpacePreserve (xmlNodePtr cur, int val); xmlChar* xmlNodeGetBase (xmlDocPtr doc, xmlNodePtr cur); void xmlNodeSetBase (xmlNodePtr cur, xmlChar *uri); int xmlRemoveProp (xmlAttrPtr cur); int xmlUnsetProp (xmlNodePtr node, const xmlChar *name); int xmlUnsetNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name); void xmlBufferWriteCHAR (xmlBufferPtr buf, const xmlChar *string); void xmlBufferWriteChar (xmlBufferPtr buf, const char *string); void xmlBufferWriteQuotedString (xmlBufferPtr buf, const xmlChar *string); int xmlReconciliateNs (xmlDocPtr doc, xmlNodePtr tree); void xmlDocDumpFormatMemory (xmlDocPtr cur, xmlChar **mem, int *size, int format); void xmlDocDumpMemory (xmlDocPtr cur, xmlChar **mem, int *size); void xmlDocDumpMemoryEnc (xmlDocPtr out_doc, xmlChar **doc_txt_ptr, int *doc_txt_len, const char *txt_encoding); void xmlDocDumpFormatMemoryEnc (xmlDocPtr out_doc, xmlChar **doc_txt_ptr, int *doc_txt_len, const char *txt_encoding, int format); int xmlDocFormatDump (FILE *f, xmlDocPtr cur, int format); int xmlDocDump (FILE *f, xmlDocPtr cur); void xmlElemDump (FILE *f, xmlDocPtr doc, xmlNodePtr cur); int xmlSaveFile (const char *filename, xmlDocPtr cur); int xmlSaveFormatFile (const char *filename, xmlDocPtr cur, int format); int xmlNodeDump (xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, int format); int xmlSaveFileTo (xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding); int xmlSaveFormatFileTo (xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding, int format); void xmlNodeDumpOutput (xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, int format, const char *encoding); int xmlSaveFormatFileEnc (const char *filename, xmlDocPtr cur, const char *encoding, int format); int xmlSaveFileEnc (const char *filename, xmlDocPtr cur, const char *encoding); int xmlIsXHTML (const xmlChar *systemID, const xmlChar *publicID); int xmlGetDocCompressMode (xmlDocPtr doc); void xmlSetDocCompressMode (xmlDocPtr doc, int mode); int xmlGetCompressMode (void); void xmlSetCompressMode (int mode);
struct xmlParserInputBuffer { void* context; xmlInputReadCallback readcallback; xmlInputCloseCallback closecallback; xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */ xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */ };
struct xmlOutputBuffer { void* context; xmlOutputWriteCallback writecallback; xmlOutputCloseCallback closecallback; xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ xmlBufferPtr conv; /* if encoder != NULL buffer for output */ int written; /* total number of byte written */ };
struct xmlParserInput { /* Input buffer */ xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ const char *filename; /* The file analyzed, if any */ const char *directory; /* the directory/base of the file */ const xmlChar *base; /* Base of the array to parse */ const xmlChar *cur; /* Current char being parsed */ const xmlChar *end; /* end of the array to parse */ int length; /* length if known */ int line; /* Current line */ int col; /* Current column */ /* * NOTE: consumed is only tested for equality in the parser code, * so even if there is an overflow this should not give troubles * for parsing very large instances. */ unsigned long consumed; /* How many xmlChars already consumed */ xmlParserInputDeallocate free; /* function to deallocate the base */ const xmlChar *encoding; /* the encoding string for entity */ const xmlChar *version; /* the version string for entity */ int standalone; /* Was that entity marked standalone */ };
An xmlParserInput is an input flow for the XML processor. Each entity parsed is associated an xmlParserInput (except the few predefined ones). This is the case both for internal entities - in which case the flow is already completely in memory - or external entities - in which case we use the buf structure for progressive reading and I18N conversions to the internal UTF-8 format.
struct xmlParserCtxt { struct _xmlSAXHandler *sax; /* The SAX handler */ void *userData; /* For SAX interface only, used by DOM build */ xmlDocPtr myDoc; /* the document being built */ int wellFormed; /* is the document well formed */ int replaceEntities; /* shall we replace entities ? */ const xmlChar *version; /* the XML version string */ const xmlChar *encoding; /* the declared encoding, if any */ int standalone; /* standalone document */ int html; /* an HTML(1)/Docbook(2) document */ /* Input stream stack */ xmlParserInputPtr input; /* Current input stream */ int inputNr; /* Number of current input streams */ int inputMax; /* Max number of input streams */ xmlParserInputPtr *inputTab; /* stack of inputs */ /* Node analysis stack only used for DOM building */ xmlNodePtr node; /* Current parsed Node */ int nodeNr; /* Depth of the parsing stack */ int nodeMax; /* Max depth of the parsing stack */ xmlNodePtr *nodeTab; /* array of nodes */ int record_info; /* Whether node info should be kept */ xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ int errNo; /* error code */ int hasExternalSubset; /* reference and external subset */ int hasPErefs; /* the internal subset has PE refs */ int external; /* are we parsing an external entity */ int valid; /* is the document valid */ int validate; /* shall we try to validate ? */ xmlValidCtxt vctxt; /* The validity context */ xmlParserInputState instate; /* current type of input */ int token; /* next char look-ahead */ char *directory; /* the data directory */ /* Node name stack */ xmlChar *name; /* Current parsed Node */ int nameNr; /* Depth of the parsing stack */ int nameMax; /* Max depth of the parsing stack */ xmlChar * *nameTab; /* array of nodes */ long nbChars; /* number of xmlChar processed */ long checkIndex; /* used by progressive parsing lookup */ int keepBlanks; /* ugly but ... */ int disableSAX; /* SAX callbacks are disabled */ int inSubset; /* Parsing is in int 1/ext 2 subset */ xmlChar * intSubName; /* name of subset */ xmlChar * extSubURI; /* URI of external subset */ xmlChar * extSubSystem; /* SYSTEM ID of external subset */ /* xml:space values */ int * space; /* Should the parser preserve spaces */ int spaceNr; /* Depth of the parsing stack */ int spaceMax; /* Max depth of the parsing stack */ int * spaceTab; /* array of space infos */ int depth; /* to prevent entity substitution loops */ xmlParserInputPtr entity; /* used to check entities boundaries */ int charset; /* encoding of the in-memory content actually an xmlCharEncoding */ int nodelen; /* Those two fields are there to */ int nodemem; /* Speed up large node parsing */ int pedantic; /* signal pedantic warnings */ void *_private; /* For user data, libxml won't touch it */ int loadsubset; /* should the external subset be loaded */ int linenumbers; /* set line number in element content */ void *catalogs; /* document's own catalog */ int recovery; /* run in recovery mode */ int progressive; /* is this a progressive parsing */ };
The parser context. NOTE This doesn't completely define the parser state, the (current ?) design of the parser uses recursive function calls since this allow and easy mapping from the production rules of the specification to the actual code. The drawback is that the actual function call also reflect the parser state. However most of the parsing routines takes as the only argument the parser context pointer, so migrating to a state based parser for progressive parsing shouldn't be too hard.
struct xmlSAXLocator { const xmlChar *(*getPublicId)(void *ctx); const xmlChar *(*getSystemId)(void *ctx); int (*getLineNumber)(void *ctx); int (*getColumnNumber)(void *ctx); };
A SAX Locator.
struct xmlSAXHandler { internalSubsetSAXFunc internalSubset; isStandaloneSAXFunc isStandalone; hasInternalSubsetSAXFunc hasInternalSubset; hasExternalSubsetSAXFunc hasExternalSubset; resolveEntitySAXFunc resolveEntity; getEntitySAXFunc getEntity; entityDeclSAXFunc entityDecl; notationDeclSAXFunc notationDecl; attributeDeclSAXFunc attributeDecl; elementDeclSAXFunc elementDecl; unparsedEntityDeclSAXFunc unparsedEntityDecl; setDocumentLocatorSAXFunc setDocumentLocator; startDocumentSAXFunc startDocument; endDocumentSAXFunc endDocument; startElementSAXFunc startElement; endElementSAXFunc endElement; referenceSAXFunc reference; charactersSAXFunc characters; ignorableWhitespaceSAXFunc ignorableWhitespace; processingInstructionSAXFunc processingInstruction; commentSAXFunc comment; warningSAXFunc warning; errorSAXFunc error; fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ getParameterEntitySAXFunc getParameterEntity; cdataBlockSAXFunc cdataBlock; externalSubsetSAXFunc externalSubset; int initialized; };
A SAX handler is bunch of callbacks called by the parser when processing of the input generate data or structure informations.
struct xmlEntity { void *_private; /* application data */ xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ const xmlChar *name; /* Entity name */ struct _xmlNode *children; /* First child link */ struct _xmlNode *last; /* Last child link */ struct _xmlDtd *parent; /* -> DTD */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ xmlChar *orig; /* content without ref substitution */ xmlChar *content; /* content or ndata if unparsed */ int length; /* the content length */ xmlEntityType etype; /* The entity type */ const xmlChar *ExternalID; /* External identifier for PUBLIC */ const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */ struct _xmlEntity *nexte; /* unused */ const xmlChar *URI; /* the full URI as computed */ int owner; /* does the entity own the childrens */ };
#define XML_XML_NAMESPACE
This is the namespace for the special xml: prefix predefined in the XML Namespace specification.
typedef enum { XML_ELEMENT_NODE= 1, XML_ATTRIBUTE_NODE= 2, XML_TEXT_NODE= 3, XML_CDATA_SECTION_NODE= 4, XML_ENTITY_REF_NODE= 5, XML_ENTITY_NODE= 6, XML_PI_NODE= 7, XML_COMMENT_NODE= 8, XML_DOCUMENT_NODE= 9, XML_DOCUMENT_TYPE_NODE= 10, XML_DOCUMENT_FRAG_NODE= 11, XML_NOTATION_NODE= 12, XML_HTML_DOCUMENT_NODE= 13, XML_DTD_NODE= 14, XML_ELEMENT_DECL= 15, XML_ATTRIBUTE_DECL= 16, XML_ENTITY_DECL= 17, XML_NAMESPACE_DECL= 18, XML_XINCLUDE_START= 19, XML_XINCLUDE_END= 20 #ifdef LIBXML_DOCB_ENABLED ,XML_DOCB_DOCUMENT_NODE= 21 #endif } xmlElementType;
typedef unsigned char xmlChar;
This is a basic byte in an UTF-8 encoded string. It's unsigned allowing to pinpoint case where char * are assigned to xmlChar * (possibly making serialization back impossible).
struct xmlNotation { const xmlChar *name; /* Notation name */ const xmlChar *PublicID; /* Public identifier, if any */ const xmlChar *SystemID; /* System identifier, if any */ };
A DTD Notation definition.
typedef enum { XML_ATTRIBUTE_CDATA = 1, XML_ATTRIBUTE_ID, XML_ATTRIBUTE_IDREF , XML_ATTRIBUTE_IDREFS, XML_ATTRIBUTE_ENTITY, XML_ATTRIBUTE_ENTITIES, XML_ATTRIBUTE_NMTOKEN, XML_ATTRIBUTE_NMTOKENS, XML_ATTRIBUTE_ENUMERATION, XML_ATTRIBUTE_NOTATION } xmlAttributeType;
A DTD Attribute type definition.
typedef enum { XML_ATTRIBUTE_NONE = 1, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED, XML_ATTRIBUTE_FIXED } xmlAttributeDefault;
A DTD Attribute default definition.
struct xmlEnumeration { struct _xmlEnumeration *next; /* next one */ const xmlChar *name; /* Enumeration name */ };
List structure used when there is an enumeration in DTDs.
struct xmlAttribute { void *_private; /* application data */ xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ const xmlChar *name; /* Attribute name */ struct _xmlNode *children; /* NULL */ struct _xmlNode *last; /* NULL */ struct _xmlDtd *parent; /* -> DTD */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ struct _xmlAttribute *nexth; /* next in hash table */ xmlAttributeType atype; /* The attribute type */ xmlAttributeDefault def; /* the default */ const xmlChar *defaultValue; /* or the default value */ xmlEnumerationPtr tree; /* or the enumeration tree if any */ const xmlChar *prefix; /* the namespace prefix if any */ const xmlChar *elem; /* Element holding the attribute */ };
An Attribute declaration in a DTD.
typedef enum { XML_ELEMENT_CONTENT_PCDATA = 1, XML_ELEMENT_CONTENT_ELEMENT, XML_ELEMENT_CONTENT_SEQ, XML_ELEMENT_CONTENT_OR } xmlElementContentType;
Possible definitions of element content types.
typedef enum { XML_ELEMENT_CONTENT_ONCE = 1, XML_ELEMENT_CONTENT_OPT, XML_ELEMENT_CONTENT_MULT, XML_ELEMENT_CONTENT_PLUS } xmlElementContentOccur;
Possible definitions of element content occurrences.
struct xmlElementContent { xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ const xmlChar *name; /* Element name */ struct _xmlElementContent *c1; /* first child */ struct _xmlElementContent *c2; /* second child */ struct _xmlElementContent *parent; /* parent */ const xmlChar *prefix; /* Namespace prefix */ };
An XML Element content as stored after parsing an element definition in a DTD.
typedef enum { XML_ELEMENT_TYPE_UNDEFINED = 0, XML_ELEMENT_TYPE_EMPTY = 1, XML_ELEMENT_TYPE_ANY, XML_ELEMENT_TYPE_MIXED, XML_ELEMENT_TYPE_ELEMENT } xmlElementTypeVal;
The different possibilities for an element content type.
struct xmlElement { void *_private; /* application data */ xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ const xmlChar *name; /* Element name */ struct _xmlNode *children; /* NULL */ struct _xmlNode *last; /* NULL */ struct _xmlDtd *parent; /* -> DTD */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ xmlElementTypeVal etype; /* The type */ xmlElementContentPtr content; /* the allowed element content */ xmlAttributePtr attributes; /* List of the declared attributes */ const xmlChar *prefix; /* the namespace prefix if any */ #ifdef LIBXML_REGEXP_ENABLED xmlRegexpPtr contModel; /* the validating regexp */ #else void *contModel; #endif };
An XML Element declaration from a DTD.
struct xmlNs { struct _xmlNs *next; /* next Ns link for this node */ xmlNsType type; /* global or local */ const xmlChar *href; /* URL for the namespace */ const xmlChar *prefix; /* prefix for the namespace */ void *_private; /* application data */ };
An XML namespace. Note that prefix == NULL is valid, it defines the default namespace within the subtree (until overridden).
xmlNsType is unified with xmlElementType.
struct xmlDtd { void *_private; /* application data */ xmlElementType type; /* XML_DTD_NODE, must be second ! */ const xmlChar *name; /* Name of the DTD */ struct _xmlNode *children; /* the value of the property link */ struct _xmlNode *last; /* last child link */ struct _xmlDoc *parent; /* child->parent link */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ /* End of common part */ void *notations; /* Hash table for notations if any */ void *elements; /* Hash table for elements if any */ void *attributes; /* Hash table for attributes if any */ void *entities; /* Hash table for entities if any */ const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ void *pentities; /* Hash table for param entities if any */ };
An XML DTD, as defined by <!DOCTYPE ... There is actually one for the internal subset and for the external subset.
struct xmlAttr { void *_private; /* application data */ xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ const xmlChar *name; /* the name of the property */ struct _xmlNode *children; /* the value of the property */ struct _xmlNode *last; /* NULL */ struct _xmlNode *parent; /* child->parent link */ struct _xmlAttr *next; /* next sibling link */ struct _xmlAttr *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ xmlNs *ns; /* pointer to the associated namespace */ xmlAttributeType atype; /* the attribute type if validating */ };
An attribute on an XML node.
struct xmlID { struct _xmlID *next; /* next ID */ const xmlChar *value; /* The ID name */ xmlAttrPtr attr; /* The attribute holding it */ const xmlChar *name; /* The attribute if attr is not available */ int lineno; /* The line number if attr is not available */ };
An XML ID instance.
struct xmlRef { struct _xmlRef *next; /* next Ref */ const xmlChar *value; /* The Ref name */ xmlAttrPtr attr; /* The attribute holding it */ const xmlChar *name; /* The attribute if attr is not available */ int lineno; /* The line number if attr is not available */ };
An XML IDREF instance.
typedef enum { XML_BUFFER_ALLOC_DOUBLEIT, XML_BUFFER_ALLOC_EXACT } xmlBufferAllocationScheme;
A buffer allocation scheme can be defined to either match exactly the need or double it's allocated size each time it is found too small.
struct xmlBuffer { xmlChar *content; /* The buffer content UTF8 */ unsigned int use; /* The buffer size used */ unsigned int size; /* The buffer size */ xmlBufferAllocationScheme alloc; /* The realloc method */ };
A buffer structure.
struct xmlNode { void *_private; /* application data */ xmlElementType type; /* type number, must be second ! */ const xmlChar *name; /* the name of the node, or the entity */ struct _xmlNode *children; /* parent->childs link */ struct _xmlNode *last; /* last child link */ struct _xmlNode *parent; /* child->parent link */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ /* End of common part */ xmlNs *ns; /* pointer to the associated namespace */ xmlChar *content; /* the content */ struct _xmlAttr *properties;/* properties list */ xmlNs *nsDef; /* namespace definitions on this node */ };
A node in an XML tree.
#define XML_GET_LINE(n)
Macro to extract the line number of an element node. This will work only if line numbering is activated by calling xmlLineNumbersDefault(1) before parsing.
n : |
struct xmlDoc { void *_private; /* application data */ xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ char *name; /* name/filename/URI of the document */ struct _xmlNode *children; /* the document tree */ struct _xmlNode *last; /* last child link */ struct _xmlNode *parent; /* child->parent link */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* autoreference to itself */ /* End of common part */ int compression;/* level of zlib compression */ int standalone; /* standalone document (no external refs) */ struct _xmlDtd *intSubset; /* the document internal subset */ struct _xmlDtd *extSubset; /* the document external subset */ struct _xmlNs *oldNs; /* Global namespace, the old way */ const xmlChar *version; /* the XML version string */ const xmlChar *encoding; /* external initial encoding, if any */ void *ids; /* Hash table for ID attributes if any */ void *refs; /* Hash table for IDREFs attributes if any */ const xmlChar *URL; /* The URI for that document */ int charset; /* encoding of the in-memory content actually an xmlCharEncoding */ };
An XML document.
int xmlValidateNCName (const xmlChar *value, int space);
Check that a value conforms to the lexical space of NCName
value : | the value to check |
space : | allow 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. |
int xmlValidateQName (const xmlChar *value, int space);
Check that a value conforms to the lexical space of QName
value : | the value to check |
space : | allow 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. |
int xmlValidateName (const xmlChar *value, int space);
Check that a value conforms to the lexical space of Name
value : | the value to check |
space : | allow 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. |
int xmlValidateNMToken (const xmlChar *value, int space);
Check that a value conforms to the lexical space of NMToken
value : | the value to check |
space : | allow 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. |
xmlChar* xmlBuildQName (const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len);
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.
ncname : | the Name |
prefix : | the prefix |
memory : | preallocated memory |
len : | preallocated 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 |
xmlChar* xmlSplitQName2 (const xmlChar *name, xmlChar **prefix);
parse an XML qualified name string
[NS 5] QName ::= (Prefix ':')? LocalPart
[NS 6] Prefix ::= NCName
[NS 7] LocalPart ::= NCName
name : | the full QName |
prefix : | a xmlChar ** |
Returns : | NULL if not a QName, otherwise the local part, and prefix is updated to get the Prefix if any. |
void xmlSetBufferAllocationScheme (xmlBufferAllocationScheme scheme);
Set the buffer allocation method. Types are XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, improves performance
scheme : | allocation method to use |
xmlBufferAllocationScheme xmlGetBufferAllocationScheme (void);
Types are XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, improves performance
Returns : | the current allocation scheme |
xmlBufferPtr xmlBufferCreate (void);
routine to create an XML buffer.
Returns : | the new structure. |
xmlBufferPtr xmlBufferCreateSize (size_t size);
routine to create an XML buffer.
size : | initial size of buffer |
Returns : | the new structure. |
int xmlBufferResize (xmlBufferPtr buf, unsigned int size);
Resize a buffer to accommodate minimum size of size.
buf : | the buffer to resize |
size : | the desired size |
Returns : | 0 in case of problems, 1 otherwise |
void xmlBufferFree (xmlBufferPtr buf);
Frees an XML buffer. It frees both the content and the structure which encapsulate it.
buf : | the buffer to free |
int xmlBufferDump (FILE *file, xmlBufferPtr buf);
Dumps an XML buffer to a FILE *.
file : | the file output |
buf : | the buffer to dump |
Returns : | the number of xmlChar written |
void xmlBufferAdd (xmlBufferPtr buf, const xmlChar *str, int len);
Add a string range to an XML buffer. if len == -1, the length of str is recomputed.
void xmlBufferAddHead (xmlBufferPtr buf, const xmlChar *str, int len);
Add a string range to the beginning of an XML buffer. if len == -1, the length of str is recomputed.
void xmlBufferCat (xmlBufferPtr buf, const xmlChar *str);
Append a zero terminated string to an XML buffer.
buf : | the buffer to dump |
str : | the xmlChar string |
void xmlBufferCCat (xmlBufferPtr buf, const char *str);
Append a zero terminated C string to an XML buffer.
buf : | the buffer to dump |
str : | the C char string |
int xmlBufferShrink (xmlBufferPtr buf, unsigned int len);
Remove the beginning of an XML buffer.
buf : | the buffer to dump |
len : | the number of xmlChar to remove |
Returns : | the number of xmlChar removed, or -1 in case of failure. |
int xmlBufferGrow (xmlBufferPtr buf, unsigned int len);
Grow the available space of an XML buffer.
buf : | the buffer |
len : | the minimum free size to allocate |
Returns : | the new available space or -1 in case of error |
const xmlChar* xmlBufferContent (const xmlBufferPtr buf);
Function to extract the content of a buffer
buf : | the buffer |
Returns : | the internal content |
void xmlBufferSetAllocationScheme (xmlBufferPtr buf, xmlBufferAllocationScheme scheme);
Sets the allocation scheme for this buffer
buf : | the buffer to tune |
scheme : | allocation scheme to use |
int xmlBufferLength (const xmlBufferPtr buf);
Function to get the length of a buffer
buf : | the buffer |
Returns : | the length of data in the internal content |
xmlDtdPtr xmlCreateIntSubset (xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID);
Create the internal subset of a document
doc : | the document pointer |
name : | the DTD name |
ExternalID : | the external (PUBLIC) ID |
SystemID : | the system ID |
Returns : | a pointer to the new DTD structure |
xmlDtdPtr xmlNewDtd (xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID);
Creation of a new DTD for the external subset. To create an internal subset, use xmlCreateIntSubset().
doc : | the document pointer |
name : | the DTD name |
ExternalID : | the external ID |
SystemID : | the system ID |
Returns : | a pointer to the new DTD structure |
xmlDtdPtr xmlGetIntSubset (xmlDocPtr doc);
Get the internal subset of a document
doc : | the document pointer |
Returns : | a pointer to the DTD structure or NULL if not found |
void xmlFreeDtd (xmlDtdPtr cur);
Free a DTD structure.
cur : | the DTD structure to free up |
xmlNsPtr xmlNewGlobalNs (xmlDocPtr doc, const xmlChar *href, const xmlChar *prefix);
Creation of a Namespace, the old way using PI and without scoping DEPRECATED !!! It now create a namespace on the root element of the document if found.
doc : | the document carrying the namespace |
href : | the URI associated |
prefix : | the prefix for the namespace |
Returns : | NULL this functionality had been removed |
xmlNsPtr xmlNewNs (xmlNodePtr node, const xmlChar *href, const xmlChar *prefix);
Creation of a new Namespace. This function will refuse to create a namespace with a similar prefix than an existing one present on this node. We use href==NULL in the case of an element creation where the namespace was not defined.
node : | the element carrying the namespace |
href : | the URI associated |
prefix : | the prefix for the namespace |
Returns : | a new namespace pointer or NULL |
void xmlFreeNs (xmlNsPtr cur);
Free up the structures associated to a namespace
cur : | the namespace pointer |
void xmlFreeNsList (xmlNsPtr cur);
Free up all the structures associated to the chained namespaces.
cur : | the first namespace pointer |
xmlDocPtr xmlNewDoc (const xmlChar *version);
Creates a new XML document
version : | xmlChar string giving the version of XML "1.0" |
Returns : | a new document |
void xmlFreeDoc (xmlDocPtr cur);
Free up all the structures used by a document, tree included.
cur : | pointer to the document |
xmlAttrPtr xmlNewDocProp (xmlDocPtr doc, const xmlChar *name, const xmlChar *value);
Create a new property carried by a document.
doc : | the document |
name : | the name of the attribute |
value : | the value of the attribute |
Returns : | a pointer to the attribute |
xmlAttrPtr xmlNewProp (xmlNodePtr node, const xmlChar *name, const xmlChar *value);
Create a new property carried by a node.
node : | the holding node |
name : | the name of the attribute |
value : | the value of the attribute |
Returns : | a pointer to the attribute |
xmlAttrPtr xmlNewNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value);
Create a new property tagged with a namespace and carried by a node.
node : | the holding node |
ns : | the namespace |
name : | the name of the attribute |
value : | the value of the attribute |
Returns : | a pointer to the attribute |
xmlAttrPtr xmlNewNsPropEatName (xmlNodePtr node, xmlNsPtr ns, xmlChar *name, const xmlChar *value);
Create a new property tagged with a namespace and carried by a node.
node : | the holding node |
ns : | the namespace |
name : | the name of the attribute |
value : | the value of the attribute |
Returns : | a pointer to the attribute |
void xmlFreePropList (xmlAttrPtr cur);
Free a property and all its siblings, all the children are freed too.
cur : | the first property in the list |
void xmlFreeProp (xmlAttrPtr cur);
Free one attribute, all the content is freed too
cur : | an attribute |
xmlAttrPtr xmlCopyProp (xmlNodePtr target, xmlAttrPtr cur);
Do a copy of the attribute.
target : | the element where the attribute will be grafted |
cur : | the attribute |
Returns : | a new xmlAttrPtr, or NULL in case of error. |
xmlAttrPtr xmlCopyPropList (xmlNodePtr target, xmlAttrPtr cur);
Do a copy of an attribute list.
target : | the element where the attributes will be grafted |
cur : | the first attribute |
Returns : | a new xmlAttrPtr, or NULL in case of error. |
xmlDtdPtr xmlCopyDtd (xmlDtdPtr dtd);
Do a copy of the dtd.
dtd : | the dtd |
Returns : | a new xmlDtdPtr, or NULL in case of error. |
xmlDocPtr xmlCopyDoc (xmlDocPtr doc, int recursive);
Do a copy of the document info. If recursive, the content tree will be copied too as well as DTD, namespaces and entities.
doc : | the document |
recursive : | if 1 do a recursive copy. |
Returns : | a new xmlDocPtr, or NULL in case of error. |
xmlNodePtr xmlNewDocNode (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content);
Creation of a new node element within a document. ns and content are optional (NULL). NOTE: content is supposed to be a piece of XML CDATA, so it allow entities references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't need entities support.
doc : | the document |
ns : | namespace if any |
name : | the node name |
content : | the XML text content if any |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewDocNodeEatName (xmlDocPtr doc, xmlNsPtr ns, xmlChar *name, const xmlChar *content);
Creation of a new node element within a document. ns and content are optional (NULL). NOTE: content is supposed to be a piece of XML CDATA, so it allow entities references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewDocRawNode() if you don't need entities support.
doc : | the document |
ns : | namespace if any |
name : | the node name |
content : | the XML text content if any |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewDocRawNode (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content);
Creation of a new node element within a document. ns and content are optional (NULL).
doc : | the document |
ns : | namespace if any |
name : | the node name |
content : | the text content if any |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewNode (xmlNsPtr ns, const xmlChar *name);
Creation of a new node element. ns is optional (NULL).
ns : | namespace if any |
name : | the node name |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewNodeEatName (xmlNsPtr ns, xmlChar *name);
Creation of a new node element. ns is optional (NULL).
ns : | namespace if any |
name : | the node name |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewChild (xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content);
Creation of a new child element, added at the end of parent children list. ns and content parameters are optional (NULL). If content is non NULL, a child list containing the TEXTs and ENTITY_REFs node will be created. NOTE: content is supposed to be a piece of XML CDATA, so it allow entities references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant(). Use xmlNewTextChild() if entities support is not needed.
parent : | the parent node |
ns : | a namespace if any |
name : | the name of the child |
content : | the XML content of the child if any. |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewTextChild (xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content);
Creation of a new child element, added at the end of parent children list. ns and content parameters are optional (NULL). If content is non NULL, a child TEXT node will be created containing the string content.
parent : | the parent node |
ns : | a namespace if any |
name : | the name of the child |
content : | the text content of the child if any. |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewDocText (xmlDocPtr doc, const xmlChar *content);
Creation of a new text node within a document.
doc : | the document |
content : | the text content |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewText (const xmlChar *content);
Creation of a new text node.
content : | the text content |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewPI (const xmlChar *name, const xmlChar *content);
Creation of a processing instruction element.
name : | the processing instruction name |
content : | the PI content |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewDocTextLen (xmlDocPtr doc, const xmlChar *content, int len);
Creation of a new text node with an extra content length parameter. The text node pertain to a given document.
doc : | the document |
content : | the text content |
len : | the text len. |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewTextLen (const xmlChar *content, int len);
Creation of a new text node with an extra parameter for the content's length
content : | the text content |
len : | the text len. |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewDocComment (xmlDocPtr doc, const xmlChar *content);
Creation of a new node containing a comment within a document.
doc : | the document |
content : | the comment content |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewComment (const xmlChar *content);
Creation of a new node containing a comment.
content : | the comment content |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewCDataBlock (xmlDocPtr doc, const xmlChar *content, int len);
Creation of a new node containing a CDATA block.
doc : | the document |
content : | the CDATA block content content |
len : | the length of the block |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewCharRef (xmlDocPtr doc, const xmlChar *name);
Creation of a new character reference node.
doc : | the document |
name : | the char ref string, starting with # or "&# ... ;" |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlNewReference (xmlDocPtr doc, const xmlChar *name);
Creation of a new reference node.
doc : | the document |
name : | the reference name, or the reference string with & and ; |
Returns : | a pointer to the new node object. |
xmlNodePtr xmlCopyNode (const xmlNodePtr node, int recursive);
Do a copy of the node.
node : | the node |
recursive : | if 1 do a recursive copy. |
Returns : | a new xmlNodePtr, or NULL in case of error. |
xmlNodePtr xmlDocCopyNode (const xmlNodePtr node, xmlDocPtr doc, int recursive);
Do a copy of the node to a given document.
node : | the node |
doc : | the document |
recursive : | if 1 do a recursive copy. |
Returns : | a new xmlNodePtr, or NULL in case of error. |
xmlNodePtr xmlCopyNodeList (const xmlNodePtr node);
Do a recursive copy of the node list.
node : | the first node in the list. |
Returns : | a new xmlNodePtr, or NULL in case of error. |
xmlNodePtr xmlNewDocFragment (xmlDocPtr doc);
Creation of a new Fragment node.
doc : | the document owning the fragment |
Returns : | a pointer to the new node object. |
long xmlGetLineNo (xmlNodePtr node);
Get line number of node. this requires activation of this option before invoking the parser by calling xmlLineNumbersDefault(1)
node : | valid node |
Returns : | the line number if successful, -1 otherwise |
xmlChar* xmlGetNodePath (xmlNodePtr node);
Build a structure based Path for the given node
node : | a node |
Returns : | the new path or NULL in case of error. The caller must free the returned string |
xmlNodePtr xmlDocGetRootElement (xmlDocPtr doc);
Get the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...).
doc : | the document |
Returns : | the xmlNodePtr for the root or NULL |
xmlNodePtr xmlGetLastChild (xmlNodePtr parent);
Search the last child of a node.
parent : | the parent node |
Returns : | the last child or NULL if none. |
int xmlNodeIsText (xmlNodePtr node);
Is this node a Text node ?
node : | the node |
Returns : | 1 yes, 0 no |
int xmlIsBlankNode (xmlNodePtr node);
Checks whether this node is an empty or whitespace only (and possibly ignorable) text-node.
node : | the node |
Returns : | 1 yes, 0 no |
xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc, xmlNodePtr root);
Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...).
doc : | the document |
root : | the new document root element |
Returns : | the old root element if any was found |
void xmlNodeSetName (xmlNodePtr cur, const xmlChar *name);
Set (or reset) the name of a node.
cur : | the node being changed |
name : | the new tag name |
xmlNodePtr xmlAddChild (xmlNodePtr parent, xmlNodePtr cur);
Add a new node to parent, at the end of the child (or property) list merging adjacent TEXT nodes (in which case cur is freed) If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed.
parent : | the parent node |
cur : | the child node |
Returns : | the child or NULL in case of error. |
xmlNodePtr xmlAddChildList (xmlNodePtr parent, xmlNodePtr cur);
Add a list of node at the end of the child list of the parent merging adjacent TEXT nodes (cur may be freed)
parent : | the parent node |
cur : | the first node in the list |
Returns : | the last child or NULL in case of error. |
xmlNodePtr xmlReplaceNode (xmlNodePtr old, xmlNodePtr cur);
Unlink the old node from it's current context, prune the new one at the same place. If cur was already inserted in a document it is first unlinked from its existing context.
old : | the old node |
cur : | the node |
Returns : | the old node |
xmlNodePtr xmlAddSibling (xmlNodePtr cur, xmlNodePtr elem);
Add a new element elem to the list of siblings of cur merging adjacent TEXT nodes (elem may be freed) If the new element was already inserted in a document it is first unlinked from its existing context.
cur : | the child node |
elem : | the new node |
Returns : | the new element or NULL in case of error. |
xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur, xmlNodePtr elem);
Add a new node elem as the previous sibling of cur merging adjacent TEXT nodes (elem may be freed) If the new node was already inserted in a document it is first unlinked from its existing context. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed.
cur : | the child node |
elem : | the new node |
Returns : | the new node or NULL in case of error. |
xmlNodePtr xmlAddNextSibling (xmlNodePtr cur, xmlNodePtr elem);
Add a new node elem as the next sibling of cur If the new node was already inserted in a document it is first unlinked from its existing context. As a result of text merging elem may be freed. If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed.
cur : | the child node |
elem : | the new node |
Returns : | the new node or NULL in case of error. |
void xmlUnlinkNode (xmlNodePtr cur);
Unlink a node from it's current context, the node is not freed
cur : | the node |
xmlNodePtr xmlTextMerge (xmlNodePtr first, xmlNodePtr second);
Merge two text nodes into one
first : | the first text node |
second : | the second text node being merged |
Returns : | the first text node augmented |
int xmlTextConcat (xmlNodePtr node, const xmlChar *content, int len);
Concat the given string at the end of the existing node content
node : | the node |
content : | the content |
len : | content length |
Returns : | -1 in case of error, 0 otherwise |
void xmlFreeNodeList (xmlNodePtr cur);
Free a node and all its siblings, this is a recursive behaviour, all the children are freed too.
cur : | the first node in the list |
void xmlFreeNode (xmlNodePtr cur);
Free a node, this is a recursive behaviour, all the children are freed too. This doesn't unlink the child from the list, use xmlUnlinkNode() first.
cur : | the node |
void xmlSetTreeDoc (xmlNodePtr tree, xmlDocPtr doc);
update all nodes under the tree to point to the right document
tree : | the top element |
doc : | the document |
void xmlSetListDoc (xmlNodePtr list, xmlDocPtr doc);
update all nodes in the list to point to the right document
list : | the first element |
doc : | the document |
xmlNsPtr xmlSearchNs (xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace);
Search a Ns registered under a given name space for a document. recurse on the parents until it finds the defined namespace or return NULL otherwise. nameSpace can be NULL, this is a search for the default namespace. We don't allow to cross entities boundaries. If you don't declare the namespace within those you will be in troubles !!! A warning is generated to cover this case.
doc : | the document |
node : | the current node |
nameSpace : | the namespace prefix |
Returns : | the namespace pointer or NULL. |
xmlNsPtr xmlSearchNsByHref (xmlDocPtr doc, xmlNodePtr node, const xmlChar *href);
Search a Ns aliasing a given URI. Recurse on the parents until it finds the defined namespace or return NULL otherwise.
doc : | the document |
node : | the current node |
href : | the namespace value |
Returns : | the namespace pointer or NULL. |
xmlNsPtr* xmlGetNsList (xmlDocPtr doc, xmlNodePtr node);
Search all the namespace applying to a given element.
doc : | the document |
node : | the current node |
Returns : | an NULL terminated array of all the xmlNsPtr found that need to be freed by the caller or NULL if no namespace if defined |
void xmlSetNs (xmlNodePtr node, xmlNsPtr ns);
Associate a namespace to a node, a posteriori.
node : | a node in the document |
ns : | a namespace pointer |
xmlNsPtr xmlCopyNamespace (xmlNsPtr cur);
Do a copy of the namespace.
cur : | the namespace |
Returns : | a new xmlNsPtr, or NULL in case of error. |
xmlNsPtr xmlCopyNamespaceList (xmlNsPtr cur);
Do a copy of an namespace list.
cur : | the first namespace |
Returns : | a new xmlNsPtr, or NULL in case of error. |
xmlAttrPtr xmlSetProp (xmlNodePtr node, const xmlChar *name, const xmlChar *value);
Set (or reset) an attribute carried by a node.
node : | the node |
name : | the attribute name |
value : | the attribute value |
Returns : | the attribute pointer. |
xmlChar* xmlGetProp (xmlNodePtr node, const xmlChar *name);
Search and get the value of an attribute associated to a node
This does the entity substitution.
This function looks in DTD attribute declaration for
node : | the node |
name : | the attribute name |
Returns : | the attribute value or NULL if not found. It's up to the caller to free the memory with xmlFree(). |
xmlChar* xmlGetNoNsProp (xmlNodePtr node, const xmlChar *name);
Search and get the value of an attribute associated to a node
This does the entity substitution.
This function looks in DTD attribute declaration for
node : | the node |
name : | the attribute name |
Returns : | the attribute value or NULL if not found. It's up to the caller to free the memory with xmlFree(). |
xmlAttrPtr xmlHasProp (xmlNodePtr node, const xmlChar *name);
Search an attribute associated to a node
This function also looks in DTD attribute declaration for
node : | the node |
name : | the attribute name |
Returns : | the attribute or the attribute declaration or NULL if neither was found. |
xmlAttrPtr xmlHasNsProp (xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace);
Search for an attribute associated to a node
This attribute has to be anchored in the namespace specified.
This does the entity substitution.
This function looks in DTD attribute declaration for
node : | the node |
name : | the attribute name |
nameSpace : | the URI of the namespace |
Returns : | the attribute or the attribute declaration or NULL if neither was found. |
xmlAttrPtr xmlSetNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value);
Set (or reset) an attribute carried by a node. The ns structure must be in scope, this is not checked.
node : | the node |
ns : | the namespace definition |
name : | the attribute name |
value : | the attribute value |
Returns : | the attribute pointer. |
xmlChar* xmlGetNsProp (xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace);
Search and get the value of an attribute associated to a node
This attribute has to be anchored in the namespace specified.
This does the entity substitution.
This function looks in DTD attribute declaration for
node : | the node |
name : | the attribute name |
nameSpace : | the URI of the namespace |
Returns : | the attribute value or NULL if not found. It's up to the caller to free the memory with xmlFree(). |
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc, const xmlChar *value);
Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs.
doc : | the document |
value : | the value of the attribute |
Returns : | a pointer to the first child |
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc, const xmlChar *value, int len);
Parse the value string and build the node list associated. Should produce a flat tree with only TEXTs and ENTITY_REFs.
doc : | the document |
value : | the value of the text |
len : | the length of the string value |
Returns : | a pointer to the first child |
xmlChar* xmlNodeListGetString (xmlDocPtr doc, xmlNodePtr list, int inLine);
Build the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs
doc : | the document |
list : | a Node list |
inLine : | should we replace entity contents or show their external form |
Returns : | a pointer to the string copy, the caller must free it with xmlFree(). |
xmlChar* xmlNodeListGetRawString (xmlDocPtr doc, xmlNodePtr list, int inLine);
Builds the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs, contrary to xmlNodeListGetString() this function doesn't do any character encoding handling.
doc : | the document |
list : | a Node list |
inLine : | should we replace entity contents or show their external form |
Returns : | a pointer to the string copy, the caller must free it with xmlFree(). |
void xmlNodeSetContent (xmlNodePtr cur, const xmlChar *content);
Replace the content of a node.
cur : | the node being modified |
content : | the new value of the content |
void xmlNodeSetContentLen (xmlNodePtr cur, const xmlChar *content, int len);
Replace the content of a node.
cur : | the node being modified |
content : | the new value of the content |
len : | the size of content |
void xmlNodeAddContent (xmlNodePtr cur, const xmlChar *content);
Append the extra substring to the node content.
cur : | the node being modified |
content : | extra content |
void xmlNodeAddContentLen (xmlNodePtr cur, const xmlChar *content, int len);
Append the extra substring to the node content.
cur : | the node being modified |
content : | extra content |
len : | the size of content |
xmlChar* xmlNodeGetContent (xmlNodePtr cur);
Read the value of a node, this can be either the text carried directly by this node if it's a TEXT node or the aggregate string of the values carried by this node child's (TEXT and ENTITY_REF). Entity references are substituted.
xmlChar* xmlNodeGetLang (xmlNodePtr cur);
Searches the language of a node, i.e. the values of the xml:lang attribute or the one carried by the nearest ancestor.
cur : | the 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(). |
void xmlNodeSetLang (xmlNodePtr cur, const xmlChar *lang);
Set the language of a node, i.e. the values of the xml:lang attribute.
cur : | the node being changed |
lang : | the language description |
int xmlNodeGetSpacePreserve (xmlNodePtr cur);
Searches the space preserving behaviour of a node, i.e. the values of the xml:space attribute or the one carried by the nearest ancestor.
cur : | the node being checked |
Returns : | -1 if xml:space is not inherited, 0 if "default", 1 if "preserve" |
void xmlNodeSetSpacePreserve (xmlNodePtr cur, int val);
Set (or reset) the space preserving behaviour of a node, i.e. the value of the xml:space attribute.
cur : | the node being changed |
val : | the xml:space value ("0": default, 1: "preserve") |
xmlChar* xmlNodeGetBase (xmlDocPtr doc, xmlNodePtr cur);
Searches for the BASE URL. 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 : | the document the node pertains to |
cur : | the 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(). |
void xmlNodeSetBase (xmlNodePtr cur, xmlChar *uri);
Set (or reset) the base URI of a node, i.e. the value of the xml:base attribute.
cur : | the node being changed |
uri : | the new base URI |
int xmlRemoveProp (xmlAttrPtr cur);
Unlink and free one attribute, all the content is freed too Note this doesn't work for namespace definition attributes
cur : | an attribute |
Returns : | 0 if success and -1 in case of error. |
int xmlUnsetProp (xmlNodePtr node, const xmlChar *name);
Remove an attribute carried by a node.
node : | the node |
name : | the attribute name |
Returns : | 0 if successful, -1 if not found |
int xmlUnsetNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name);
Remove an attribute carried by a node.
node : | the node |
ns : | the namespace definition |
name : | the attribute name |
Returns : | 0 if successful, -1 if not found |
void xmlBufferWriteCHAR (xmlBufferPtr buf, const xmlChar *string);
routine which manages and grows an output buffer. This one adds xmlChars at the end of the buffer.
buf : | the XML buffer |
string : | the string to add |
void xmlBufferWriteChar (xmlBufferPtr buf, const char *string);
routine which manage and grows an output buffer. This one add C chars at the end of the array.
buf : | the XML buffer output |
string : | the string to add |
void xmlBufferWriteQuotedString (xmlBufferPtr buf, const xmlChar *string);
routine which manage and grows an output buffer. This one writes a quoted or double quoted xmlChar string, checking first if it holds quote or double-quotes internally
buf : | the XML buffer output |
string : | the string to add |
int xmlReconciliateNs (xmlDocPtr doc, xmlNodePtr 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 try 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.
doc : | the document |
tree : | a node defining the subtree to reconciliate |
Returns : | the number of namespace declarations created or -1 in case of error. |
void xmlDocDumpFormatMemory (xmlDocPtr cur, xmlChar **mem, int *size, int format);
Dump an XML document in memory and return the xmlChar * and it's size. It's up to the caller to free the memory with xmlFree(). Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called
cur : | the document |
mem : | OUT: the memory pointer |
size : | OUT: the memory length |
format : | should formatting spaces been added |
void xmlDocDumpMemory (xmlDocPtr cur, xmlChar **mem, int *size);
Dump an XML document in memory and return the xmlChar * and it's size. It's up to the caller to free the memory with xmlFree().
cur : | the document |
mem : | OUT: the memory pointer |
size : | OUT: the memory length |
void xmlDocDumpMemoryEnc (xmlDocPtr out_doc, xmlChar **doc_txt_ptr, int *doc_txt_len, const char *txt_encoding);
Dump the current DOM tree into memory using the character encoding specified by the caller. Note it is up to the caller of this function to free the allocated memory with xmlFree().
out_doc : | Document to generate XML text from |
doc_txt_ptr : | Memory pointer for allocated XML text |
doc_txt_len : | Length of the generated XML text |
txt_encoding : | Character encoding to use when generating XML text |
void xmlDocDumpFormatMemoryEnc (xmlDocPtr out_doc, xmlChar **doc_txt_ptr, int *doc_txt_len, const char *txt_encoding, int format);
Dump the current DOM tree into memory using the character encoding specified by the caller. Note it is up to the caller of this function to free the allocated memory with xmlFree(). Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called
out_doc : | Document to generate XML text from |
doc_txt_ptr : | Memory pointer for allocated XML text |
doc_txt_len : | Length of the generated XML text |
txt_encoding : | Character encoding to use when generating XML text |
format : | should formatting spaces been added |
int xmlDocFormatDump (FILE *f, xmlDocPtr cur, int format);
Dump an XML document to an open FILE.
f : | the FILE* |
cur : | the document |
format : | should formatting spaces been added |
Returns : | the number of bytes written or -1 in case of failure. Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called |
int xmlDocDump (FILE *f, xmlDocPtr cur);
Dump an XML document to an open FILE.
f : | the FILE* |
cur : | the document |
Returns : | the number of bytes written or -1 in case of failure. |
void xmlElemDump (FILE *f, xmlDocPtr doc, xmlNodePtr cur);
Dump an XML/HTML node, recursive behaviour, children are printed too.
f : | the FILE * for the output |
doc : | the document |
cur : | the current node |
int xmlSaveFile (const char *filename, xmlDocPtr cur);
Dump an XML document to a file. Will use compression if compiled in and enabled. If filename is "-" the stdout file is used.
filename : | the filename (or URL) |
cur : | the document |
Returns : | the number of bytes written or -1 in case of failure. |
int xmlSaveFormatFile (const char *filename, xmlDocPtr cur, int format);
Dump an XML document to a file. Will use compression if compiled in and enabled. If filename is "-" the stdout file is used. If format is set then the document will be indented on output. Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called
filename : | the filename (or URL) |
cur : | the document |
format : | should formatting spaces been added |
Returns : | the number of bytes written or -1 in case of failure. |
int xmlNodeDump (xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, int format);
Dump an XML node, recursive behaviour,children are printed too. Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called
buf : | the XML buffer output |
doc : | the document |
cur : | the current node |
level : | the imbrication level for indenting |
format : | is formatting allowed |
Returns : | the number of bytes written to the buffer or -1 in case of error |
int xmlSaveFileTo (xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding);
Dump an XML document to an I/O buffer.
buf : | an output I/O buffer |
cur : | the document |
encoding : | the encoding if any assuming the I/O layer handles the trancoding |
Returns : | the number of bytes written or -1 in case of failure. |
int xmlSaveFormatFileTo (xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding, int format);
Dump an XML document to an I/O buffer.
buf : | an output I/O buffer |
cur : | the document |
encoding : | the encoding if any assuming the I/O layer handles the trancoding |
format : | should formatting spaces been added |
Returns : | the number of bytes written or -1 in case of failure. Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called |
void xmlNodeDumpOutput (xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, int format, const char *encoding);
Dump an XML node, recursive behaviour, children are printed too. Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called
buf : | the XML buffer output |
doc : | the document |
cur : | the current node |
level : | the imbrication level for indenting |
format : | is formatting allowed |
encoding : | an optional encoding string |
int xmlSaveFormatFileEnc (const char *filename, xmlDocPtr cur, const char *encoding, int format);
Dump an XML document to a file or an URL.
filename : | the filename or URL to output |
cur : | the document being saved |
encoding : | the name of the encoding to use or NULL. |
format : | should formatting spaces be added. |
Returns : | the number of bytes written or -1 in case of error. Note that format = 1 provide node indenting only if xmlIndentTreeOutput = 1 or xmlKeepBlanksDefault(0) was called |
int xmlSaveFileEnc (const char *filename, xmlDocPtr cur, const char *encoding);
Dump an XML document, converting it to the given encoding
filename : | the filename (or URL) |
cur : | the document |
encoding : | the name of an encoding (or NULL) |
Returns : | the number of bytes written or -1 in case of failure. |
int xmlIsXHTML (const xmlChar *systemID, const xmlChar *publicID);
Try to find if the document correspond to an XHTML DTD
systemID : | the system identifier |
publicID : | the public identifier |
Returns : | 1 if true, 0 if not and -1 in case of error |
int xmlGetDocCompressMode (xmlDocPtr doc);
get the compression ratio for a document, ZLIB based
doc : | the document |
Returns : | 0 (uncompressed) to 9 (max compression) |
void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
set the compression ratio for a document, ZLIB based Correct values: 0 (uncompressed) to 9 (max compression)
doc : | the document |
mode : | the compression ratio |
int xmlGetCompressMode (void);
get the default compression mode used, ZLIB based.
Returns : | 0 (uncompressed) to 9 (max compression) |
<< SAX | entities >> |