Panorama has several functions for working with text that contains data delimited by tags. These functions are not actually specific to HTML, and you may find other uses for them.
These functions treat a tag as three components: header, body and trailer. In this example the tag header is <
, the tag trailer is >
, and the tag body is IMG SRC="happy.gif"
.
<IMG SRC="happy.gif">
The tag header and trailer may be more than one character long. Here is the same tag but with only the picture name as the body. In this example the tag header is <IMG SRC="
, the tag trailer is ">
, and the tag body is happy.gif
.
<IMG SRC="happy.gif">
The tag functions don’t care about upper or lower case, so this tag will work fine if it is
<img src="happy.gif">.
General Tag Parsing
Here are the general tag parsing functions and statements.
- gettaglocation -- The gettaglocation statement locates the first matching tag within some text.
- gettaglocations -- The gettaglocations statement locates all matching tags within some text.
- settagdata -- The settagdata statement changes the contents of a tag.
- setxtagvalue -- The setxtagvalue statement changes the contents of a tag.
- striphtmltags( -- The striphtmltags( function removes all HTML tags from the text.
- tagarray( -- The tagarray( function builds an array (see Text Arrays) containing the body of all the specified tags (usually HTML tags) in the text.
- tagcount( -- The tagcount( function counts the number of times a specified tag (usually an HTML tag) appears in the text. See Tag Parsing for more information on HTML tags.
- tagdata( -- The tagdata( function extracts the body of the specified tag (usually an HTML tag) in the text. See Tag Parsing for more information on HTML tags.
- tagend( -- The tagend( function returns the ending position of the specified tag (usually an HTML tag) in the text.
- tagnumber( -- The tagnumber( function checks to see if a specified position is inside of a tag (usually an HTML tag).
- tagstart( -- The tagstart( function returns the starting position of the specified tag (usually an HTML tag) in the text.
- tagstrip( -- The tagstrip( function removes tags (usually HTML tags) from within a piece of text.
- xtag( -- The xtag( function generates an HTML/XML tag.
- xtagvalue( -- The xtagvalue( function extracts the text from the first matching HTML or XML tag.
Tag Parameter Parsing
Many HTML tags contain parameters. For example, this tag has three parameters: src, align and border.
<IMG SRC="mylogo.gif" align=left border=0>
Panorama has built in functions and statements that can help you extract a series of parameters like this. Although these functions were designed with parsing HTML tags in mind you may find other uses for them as well.
- settagparameter -- The settagparameter statement sets the value of a tag parameter in a list of tag parameters.
- tagparameter( -- The tagparameter( function extracts the value of a tag parameter embedded in some text, where the tag parameter takes the form name=value.
- tagparameterarray( -- The tagparameterarray( function extracts the value of multiple tag parameters embedded in some text, where each tag parameter takes the form name=value.
HTML Table Parsing Functions
These functions are specific to parsing HTML text, including functions that can extract information from an HTML table.
- htmlextractimages -- The htmlextractimages statement extracts the image URLs from an HTML page.
- htmlextractlinks -- The htmlextractlinks statement extracts the links from an HTML page.
- htmlformitemnames -- The htmlformitemnames statement returns a list of form input elements (INPUT tags, etc.) within an HTML page.
- htmltablecell( -- The htmltablecell( function extracts the data from a cell in an HTML table.
- htmltablecellexists( -- The htmltablecellexists( function returns true if an HTML table contains the specified cell, false if it doesn't.
- htmltablecellraw( -- The htmltablecellraw( function extracts the data from a cell in an HTML table (including tags, if any).
- htmltableheight( -- The htmltableheight( function calculates the height (number of rows) in an HTML table.
- htmltablerow( -- The htmltablerow( function extracts the data from a row in an HTML table.
- htmltablerowraw( -- The htmltablerowraw( function extracts the raw data (including tags, if any) from a row in an HTML table.
- htmltabletoarray -- The htmltabletoarray statement converts an HTML table into a text array.
- htmltablewidth( -- The htmltablewidth( function calculates the width (number of columns) in an HTML table.