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

HTML documents. More...

Functions

xmlDochtmlNewDoc (const xmlChar *URI, const xmlChar *ExternalID)
 Creates a new HTML document.
xmlDochtmlNewDocNoDtD (const xmlChar *URI, const xmlChar *ExternalID)
 Creates a new HTML document without a DTD node if URI and publicId are NULL.
const xmlCharhtmlGetMetaEncoding (xmlDoc *doc)
 Look up and encoding declaration in the meta tags.
int htmlSetMetaEncoding (xmlDoc *doc, const xmlChar *encoding)
 Creates or updates a meta tag with an encoding declaration.
void htmlDocDumpMemory (xmlDoc *cur, xmlChar **mem, int *size)
 Same as htmlDocDumpMemoryFormat with format set to 1 which is typically undesired.
void htmlDocDumpMemoryFormat (xmlDoc *cur, xmlChar **mem, int *size, int format)
 Serialize an HTML node to a memory, also returning the size of the result.
int htmlSaveFile (const char *filename, xmlDoc *cur)
 Serialize an HTML document to a file.
int htmlSaveFileEnc (const char *filename, xmlDoc *cur, const char *encoding)
 Serialize an HTML document to a file.
int htmlSaveFileFormat (const char *filename, xmlDoc *cur, const char *encoding, int format)
 Serialize an HTML document to a file using a given encoding.
int htmlNodeDump (xmlBuffer *buf, xmlDoc *doc, xmlNode *cur)
 Serialize an HTML node to an xmlBuffer.
int htmlDocDump (FILE *f, xmlDoc *cur)
 Serialize an HTML document to an open FILE.
void htmlNodeDumpFile (FILE *out, xmlDoc *doc, xmlNode *cur)
 Same as htmlNodeDumpFileFormat with format set to 1 which is typically undesired.
int htmlNodeDumpFileFormat (FILE *out, xmlDoc *doc, xmlNode *cur, const char *encoding, int format)
 Serialize an HTML node to an xmlBuffer.
void htmlNodeDumpOutput (xmlOutputBuffer *buf, xmlDoc *doc, xmlNode *cur, const char *encoding)
 Same as htmlNodeDumpFormatOutput with format set to 1 which is typically undesired.
void htmlNodeDumpFormatOutput (xmlOutputBuffer *buf, xmlDoc *doc, xmlNode *cur, const char *encoding, int format)
 Serialize an HTML node to an output buffer.
void htmlDocContentDumpOutput (xmlOutputBuffer *buf, xmlDoc *cur, const char *encoding)
 Same as htmlDocContentDumpFormatOutput with format set to 1 which is typically undesired.
void htmlDocContentDumpFormatOutput (xmlOutputBuffer *buf, xmlDoc *cur, const char *encoding, int format)
 Serialize an HTML document to an output buffer.
int htmlIsBooleanAttr (const xmlChar *name)
 Determine if a given attribute is a boolean attribute.

Detailed Description

HTML documents.

This modules implements functions to work with HTML documents, most of them related to serialization.

Author
Daniel Veillard

Function Documentation

◆ htmlDocContentDumpFormatOutput()

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

Serialize an HTML document to an output buffer.

Parameters
bufthe HTML buffer output
curthe document
encodingthe encoding string (unused)
formatshould formatting newlines been added

◆ htmlDocContentDumpOutput()

void htmlDocContentDumpOutput ( xmlOutputBuffer * buf,
xmlDoc * cur,
const char * encoding )

Same as htmlDocContentDumpFormatOutput with format set to 1 which is typically undesired.

Use of this function is DISCOURAGED in favor of htmlDocContentDumpFormatOutput.

Parameters
bufthe HTML buffer output
curthe document
encodingthe encoding string (unused)

◆ htmlDocDump()

int htmlDocDump ( FILE * f,
xmlDoc * cur )

Serialize an HTML document to an open FILE.

Uses the encoding of the document. If the document has no encoding, ASCII with HTML 4.0 named character entities will be used. This is inefficient compared to UTF-8 and might be changed in a future version.

Enables "formatting" unconditionally which is typically undesired.

Use of this function is DISCOURAGED in favor of htmlNodeDumpFileFormat.

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

◆ htmlDocDumpMemory()

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

Same as htmlDocDumpMemoryFormat with format set to 1 which is typically undesired.

Also see the warnings there. Use of this function is DISCOURAGED in favor of htmlDocContentDumpFormatOutput.

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

◆ htmlDocDumpMemoryFormat()

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

Serialize an HTML node to a memory, also returning the size of the result.

It's up to the caller to free the memory.

Uses the encoding of the document. If the document has no encoding, ASCII with HTML 4.0 named character entities will be used. This is inefficient compared to UTF-8 and might be changed in a future version.

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

◆ htmlGetMetaEncoding()

const xmlChar * htmlGetMetaEncoding ( xmlDoc * doc)

Look up and encoding declaration in the meta tags.

The returned string points into attribute content and can contain trailing garbage. It should be copied before modifying or freeing nodes.

Parameters
docthe document
Returns
the encoding ot NULL if not found.

◆ htmlIsBooleanAttr()

int htmlIsBooleanAttr ( const xmlChar * name)

Determine if a given attribute is a boolean attribute.

This doesn't handle HTML5.

Deprecated
Internal function, don't use.
Parameters
namethe name of the attribute to check
Returns
false if the attribute is not boolean, true otherwise.

◆ htmlNewDoc()

xmlDoc * htmlNewDoc ( const xmlChar * URI,
const xmlChar * publicId )

Creates a new HTML document.

Parameters
URIsystem ID (URI) of the DTD (optional)
publicIdpublic ID of the DTD (optional)
Returns
a new document

◆ htmlNewDocNoDtD()

xmlDoc * htmlNewDocNoDtD ( const xmlChar * URI,
const xmlChar * publicId )

Creates a new HTML document without a DTD node if URI and publicId are NULL.

Parameters
URIsystem ID (URI) of the DTD (optional)
publicIdpublic ID of the DTD (optional)
Returns
a new document, do not initialize the DTD if not provided

◆ htmlNodeDump()

int htmlNodeDump ( xmlBuffer * buf,
xmlDoc * doc,
xmlNode * cur )

Serialize an HTML node to an xmlBuffer.

Always uses UTF-8.

Parameters
bufthe HTML buffer output
docthe document
curthe current node
Returns
the number of bytes written or -1 in case of error

◆ htmlNodeDumpFile()

void htmlNodeDumpFile ( FILE * out,
xmlDoc * doc,
xmlNode * cur )

Same as htmlNodeDumpFileFormat with format set to 1 which is typically undesired.

Use of this function is DISCOURAGED in favor of htmlNodeDumpFileFormat.

Parameters
outthe FILE pointer
docthe document
curthe current node

◆ htmlNodeDumpFileFormat()

int htmlNodeDumpFileFormat ( FILE * out,
xmlDoc * doc,
xmlNode * cur,
const char * encoding,
int format )

Serialize an HTML node to an xmlBuffer.

If encoding is NULL, ASCII with HTML 4.0 named character entities will be used. This is inefficient compared to UTF-8 and might be changed in a future version.

Parameters
outthe FILE pointer
docthe document (unused)
curthe current node
encodingthe document encoding (optional)
formatshould formatting newlines been added
Returns
the number of bytes written or -1 in case of failure.

◆ htmlNodeDumpFormatOutput()

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

Serialize an HTML node to an output buffer.

Parameters
bufthe HTML buffer output
docthe document (unused)
curthe current node
encodingthe encoding string (unused)
formatshould formatting newlines been added

◆ htmlNodeDumpOutput()

void htmlNodeDumpOutput ( xmlOutputBuffer * buf,
xmlDoc * doc,
xmlNode * cur,
const char * encoding )

Same as htmlNodeDumpFormatOutput with format set to 1 which is typically undesired.

Use of this function is DISCOURAGED in favor of htmlNodeDumpFormatOutput.

Parameters
bufthe HTML buffer output
docthe document (unused)
curthe current node
encodingthe encoding string (unused)

◆ htmlSaveFile()

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

Serialize an HTML document to a file.

Same as htmlSaveFileFormat with encoding set to NULL and format set to 1 which is typically undesired.

Use of this function is DISCOURAGED in favor of htmlSaveFileFormat.

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

◆ htmlSaveFileEnc()

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

Serialize an HTML document to a file.

Same as htmlSaveFileFormat with format set to 1 which is typically undesired. Also see the warnings there. Use of this function is DISCOURAGED in favor of htmlSaveFileFormat.

Parameters
filenamethe filename
curthe document
encodingthe document encoding
Returns
the number of bytes written or -1 in case of failure.

◆ htmlSaveFileFormat()

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

Serialize an HTML document to a file using a given encoding.

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

If encoding is NULL, ASCII with HTML 4.0 named character entities will be used. This is inefficient compared to UTF-8 and might be changed in a future version.

Sets or updates meta tags containing the character encoding.

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

◆ htmlSetMetaEncoding()

int htmlSetMetaEncoding ( xmlDoc * doc,
const xmlChar * encoding )

Creates or updates a meta tag with an encoding declaration.

NOTE: This will not change the document content encoding.

Parameters
docthe document
encodingthe encoding string
Returns
0 in case of success, 1 if no head element was found or arguments are invalid and -1 if memory allocation failed.