HTML Tidy  5.6.0
The HTACG Tidy HTML Project
Document Tree

Detailed Description

A parsed (and optionally repaired) document is represented by Tidy as a tree, much like a W3C DOM.

This tree may be traversed using these functions. The following snippet gives a basic idea how these functions can be used.

void dumpNode( TidyNode tnod, int indent ) {
TidyNode child;
for ( child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) {
ctmbstr name;
switch ( tidyNodeGetType(child) ) {
case TidyNode_Root: name = "Root"; break;
case TidyNode_DocType: name = "DOCTYPE"; break;
case TidyNode_Comment: name = "Comment"; break;
case TidyNode_ProcIns: name = "Processing Instruction"; break;
case TidyNode_Text: name = "Text"; break;
case TidyNode_CDATA: name = "CDATA"; break;
case TidyNode_Section: name = "XML Section"; break;
case TidyNode_Asp: name = "ASP"; break;
case TidyNode_Jste: name = "JSTE"; break;
case TidyNode_Php: name = "PHP"; break;
case TidyNode_XmlDecl: name = "XML Declaration"; break;
default:
name = tidyNodeGetName( child );
break;
}
assert( name != NULL );
printf( "\%*.*sNode: \%s\\n", indent, indent, " ", name );
dumpNode( child, indent + 4 );
}
}
void dumpDoc( TidyDoc tdoc ) {
dumpNode( tidyGetRoot(tdoc), 0 );
}
void dumpBody( TidyDoc tdoc ) {
dumpNode( tidyGetBody(tdoc), 0 );
}

Nodes for Document Sections

TidyNode TIDY_CALL tidyGetRoot (TidyDoc tdoc)
 Get the root node. More...
 
TidyNode TIDY_CALL tidyGetHtml (TidyDoc tdoc)
 Get the HTML node. More...
 
TidyNode TIDY_CALL tidyGetHead (TidyDoc tdoc)
 Get the HEAD node. More...
 
TidyNode TIDY_CALL tidyGetBody (TidyDoc tdoc)
 Get the BODY node. More...
 

Relative Nodes

TidyNode TIDY_CALL tidyGetParent (TidyNode tnod)
 Get the parent of the indicated node. More...
 
TidyNode TIDY_CALL tidyGetChild (TidyNode tnod)
 Get the child of the indicated node. More...
 
TidyNode TIDY_CALL tidyGetNext (TidyNode tnod)
 Get the next sibling node. More...
 
TidyNode TIDY_CALL tidyGetPrev (TidyNode tnod)
 Get the previous sibling node. More...
 

Miscellaneous Node Functions

TidyNode TIDY_CALL tidyDiscardElement (TidyDoc tdoc, TidyNode tnod)
 Remove the indicated node. More...
 

Node Attribute Functions

TidyAttr TIDY_CALL tidyAttrFirst (TidyNode tnod)
 Get the first attribute. More...
 
TidyAttr TIDY_CALL tidyAttrNext (TidyAttr tattr)
 Get the next attribute. More...
 
ctmbstr TIDY_CALL tidyAttrName (TidyAttr tattr)
 Get the name of a TidyAttr instance. More...
 
ctmbstr TIDY_CALL tidyAttrValue (TidyAttr tattr)
 Get the value of a TidyAttr instance. More...
 
void TIDY_CALL tidyAttrDiscard (TidyDoc itdoc, TidyNode tnod, TidyAttr tattr)
 Discard an attribute. More...
 
TidyAttrId TIDY_CALL tidyAttrGetId (TidyAttr tattr)
 Get the attribute ID given a tidy attribute. More...
 
Bool TIDY_CALL tidyAttrIsEvent (TidyAttr tattr)
 Indicates whether or not a given attribute is an event attribute. More...
 
TidyAttr TIDY_CALL tidyAttrGetById (TidyNode tnod, TidyAttrId attId)
 Get an instance of TidyAttr by specifying an attribute ID. More...
 

Additional Node Interrogation

TidyNodeType TIDY_CALL tidyNodeGetType (TidyNode tnod)
 Get the type of node. More...
 
ctmbstr TIDY_CALL tidyNodeGetName (TidyNode tnod)
 Get the name of the node. More...
 
Bool TIDY_CALL tidyNodeIsText (TidyNode tnod)
 Indicates whether or not a node is a text node. More...
 
Bool TIDY_CALL tidyNodeIsProp (TidyDoc tdoc, TidyNode tnod)
 Indicates whether or not the node is a propriety type. More...
 
Bool TIDY_CALL tidyNodeIsHeader (TidyNode tnod)
 Indicates whether or not a node represents and HTML header element, such as h1, h2, etc. More...
 
Bool TIDY_CALL tidyNodeHasText (TidyDoc tdoc, TidyNode tnod)
 Indicates whether or not the node has text. More...
 
Bool TIDY_CALL tidyNodeGetText (TidyDoc tdoc, TidyNode tnod, TidyBuffer *buf)
 Gets the text of a node and places it into the given TidyBuffer. More...
 
Bool TIDY_CALL tidyNodeGetValue (TidyDoc tdoc, TidyNode tnod, TidyBuffer *buf)
 Get the value of the node. More...
 
TidyTagId TIDY_CALL tidyNodeGetId (TidyNode tnod)
 Get the tag ID of the node. More...
 
uint TIDY_CALL tidyNodeLine (TidyNode tnod)
 Get the line number where the node occurs. More...
 
uint TIDY_CALL tidyNodeColumn (TidyNode tnod)
 Get the column location of the node. More...
 

Function Documentation

void TIDY_CALL tidyAttrDiscard ( TidyDoc  itdoc,
TidyNode  tnod,
TidyAttr  tattr 
)

Discard an attribute.

Parameters
itdocThe tidy document from which to discard the attribute.
tnodThe node from which to discard the attribute.
tattrThe attribute to discard.
TidyAttr TIDY_CALL tidyAttrFirst ( TidyNode  tnod)

Get the first attribute.

Parameters
tnodThe node for which to get attributes.
Returns
Returns an instance of TidyAttr.
TidyAttr TIDY_CALL tidyAttrGetById ( TidyNode  tnod,
TidyAttrId  attId 
)

Get an instance of TidyAttr by specifying an attribute ID.

Returns
Returns a TidyAttr instance.
Parameters
tnodThe node to query.
attIdThe attribute ID to find.
TidyAttrId TIDY_CALL tidyAttrGetId ( TidyAttr  tattr)

Get the attribute ID given a tidy attribute.

Parameters
tattrThe attribute to query.
Returns
Returns the TidyAttrId of the given attribute.
Bool TIDY_CALL tidyAttrIsEvent ( TidyAttr  tattr)

Indicates whether or not a given attribute is an event attribute.

Parameters
tattrThe attribute to query.
Returns
Returns a bool indicating whether or not the attribute is an event.
ctmbstr TIDY_CALL tidyAttrName ( TidyAttr  tattr)

Get the name of a TidyAttr instance.

Parameters
tattrThe tidy attribute to query.
Returns
Returns a string indicating the name of the attribute.
TidyAttr TIDY_CALL tidyAttrNext ( TidyAttr  tattr)

Get the next attribute.

Parameters
tattrThe current attribute, so the next one can be returned.
Returns
Returns and instance of TidyAttr.
ctmbstr TIDY_CALL tidyAttrValue ( TidyAttr  tattr)

Get the value of a TidyAttr instance.

Parameters
tattrThe tidy attribute to query.
Returns
Returns a string indicating the value of the attribute.
TidyNode TIDY_CALL tidyDiscardElement ( TidyDoc  tdoc,
TidyNode  tnod 
)

Remove the indicated node.

Returns
Returns the next tidy node.
Parameters
tdocThe tidy document from which to remove the node.
tnodThe node to remove
TidyNode TIDY_CALL tidyGetBody ( TidyDoc  tdoc)

Get the BODY node.

Parameters
tdocThe document to query.
Returns
Returns a tidy node.
TidyNode TIDY_CALL tidyGetChild ( TidyNode  tnod)

Get the child of the indicated node.

Parameters
tnodThe node to query.
Returns
Returns a tidy node.
TidyNode TIDY_CALL tidyGetHead ( TidyDoc  tdoc)

Get the HEAD node.

Parameters
tdocThe document to query.
Returns
Returns a tidy node.
TidyNode TIDY_CALL tidyGetHtml ( TidyDoc  tdoc)

Get the HTML node.

Parameters
tdocThe document to query.
Returns
Returns a tidy node.
TidyNode TIDY_CALL tidyGetNext ( TidyNode  tnod)

Get the next sibling node.

Parameters
tnodThe node to query.
Returns
Returns a tidy node.
TidyNode TIDY_CALL tidyGetParent ( TidyNode  tnod)

Get the parent of the indicated node.

Parameters
tnodThe node to query.
Returns
Returns a tidy node.
TidyNode TIDY_CALL tidyGetPrev ( TidyNode  tnod)

Get the previous sibling node.

Parameters
tnodThe node to query.
Returns
Returns a tidy node.
TidyNode TIDY_CALL tidyGetRoot ( TidyDoc  tdoc)

Get the root node.

Parameters
tdocThe document to query.
Returns
Returns a tidy node.
uint TIDY_CALL tidyNodeColumn ( TidyNode  tnod)

Get the column location of the node.

Parameters
tnodThe node to query.
Returns
Returns the column location of the node.
TidyTagId TIDY_CALL tidyNodeGetId ( TidyNode  tnod)

Get the tag ID of the node.

Parameters
tnodThe node to query.
Returns
Returns the tag ID of the node as TidyTagId.
ctmbstr TIDY_CALL tidyNodeGetName ( TidyNode  tnod)

Get the name of the node.

Parameters
tnodThe node to query.
Returns
Returns a string indicating the name of the node.
Bool TIDY_CALL tidyNodeGetText ( TidyDoc  tdoc,
TidyNode  tnod,
TidyBuffer *  buf 
)

Gets the text of a node and places it into the given TidyBuffer.

Returns
Returns a bool indicating success or not.
Parameters
tdocThe document to query.
tnodThe node to query.
[out]bufA TidyBuffer used to receive the node's text.
TidyNodeType TIDY_CALL tidyNodeGetType ( TidyNode  tnod)

Get the type of node.

Parameters
tnodThe node to query.
Returns
Returns the type of node as TidyNodeType.
Bool TIDY_CALL tidyNodeGetValue ( TidyDoc  tdoc,
TidyNode  tnod,
TidyBuffer *  buf 
)

Get the value of the node.

This copies the unescaped value of this node into the given TidyBuffer at UTF-8.

Returns
Returns a bool indicating success or not.
Parameters
tdocThe document to query
tnodThe node to query
[out]bufA TidyBuffer used to receive the node's value.
Bool TIDY_CALL tidyNodeHasText ( TidyDoc  tdoc,
TidyNode  tnod 
)

Indicates whether or not the node has text.

Returns
Returns the type of node as TidyNodeType.
Parameters
tdocThe document to query.
tnodThe node to query.
Bool TIDY_CALL tidyNodeIsHeader ( TidyNode  tnod)

Indicates whether or not a node represents and HTML header element, such as h1, h2, etc.

Parameters
tnodThe node to query.
Returns
Returns a bool indicating whether or not the node is an HTML header.
Bool TIDY_CALL tidyNodeIsProp ( TidyDoc  tdoc,
TidyNode  tnod 
)

Indicates whether or not the node is a propriety type.

Returns
Returns a bool indicating whether or not the node is a proprietary type.
Parameters
tdocThe document to query.
tnodThe node to query
Bool TIDY_CALL tidyNodeIsText ( TidyNode  tnod)

Indicates whether or not a node is a text node.

Parameters
tnodThe node to query.
Returns
Returns a bool indicating whether or not the node is a text node.
uint TIDY_CALL tidyNodeLine ( TidyNode  tnod)

Get the line number where the node occurs.

Parameters
tnodThe node to query.
Returns
Returns the line number.