User Tools

Site Tools


Sidebar

token:token_istag

token_isTag()

Function to check whether a token is an XML/XHTML tag. You can use this function as a replacement for the RoboHelp.TagType constant. The RoboHelp.TagType constant only supports a limited number of tags and is cumbersome to use. This function supports every possible tag. Especially useful for parsing XML files. This function is the equivalent of the method .isTag()

Usage

To check whether a token is a tag, and not text:

if(token_isTag(token)) {
  //Do something if this is tag
}

To check for a specific tag: if(token_isTag(token, “p”)) {

  //Do something if this is a paragraph start tag

} </code>

To check for an array of specific tags:

//The second tag is an end paragraph tag: </p> in short.
var tags = new Array("p", "/p", "img");
if(token_isTag(token, tags)) {
   //Do something if this is one of the tags specified in the array tags
}

Note: When you check for a specific tag, specify only the name of the tag such as: p, img, etcetera. When you want to check for an end tag, specify only the backslash with the tag name: /p and /body.

Parameters

Parameter Data type Required Description
token Token object The token to check
tag array/string The name of a node ar an array with node names. If omitted the method only checks that the token is a tag
casesensitive boolean If set to true, the tag name comparison is case sensitive. Default is false

Return Values

Value String Value
true The token is one of the tags specified
false The token is not one of the tags specified
null The method encountered an error
token/token_istag.txt · Last modified: 2017/06/03 14:15 (external edit)