tagarray(
tagarray(
THETEXT
,
HEADER
,
TRAILER
,
SEPARATOR
)

The tagarray( function builds an array (see Text Arrays) containing the body of all the specified tags (usually HTML tags) in the text.

Parameters

This function has four parameters:

thetext – is the item of text that contains the data you want to extract.

header – is the text that you want to use as a tag header. For example, if you want to extract all HTML tags, use `"<"` as the header. If you wanted to extract all bold text you would use `"<B>"` as the header. (Note: Upper or lower case is ignored, so `"<b>"` will also work.)

trailer – is the text that you want to use as a tag trailer. For example, if you want to extract all HTML tags, use `">"` as the trailer. If you wanted to extract all bold text you would use `"</B>"` as the trailer. (Note: Upper or lower case is ignored, so `"</b>"` will also work.)

separator – is the separator character for the output array.

Description

This function returns an array that contains the contents of every specified tag, one tag per array item. The headers and trailers themselves are not included as part of each array item.

This example assumes you have a field or variable named myPage that contains an HTML page. The example will find and list all of the HTML tags in the page.

    local myTags
    myTags=tagarray(myPage,"<",">",";")
    arrayfilter myTags,myTags,";",?( import() notmatch "/*",import(),"")
    arraydeduplicate myTags,myTags,";"
    message myTags

The output from this example will be something like this (any tags starting with / have been removed by the arrayfilter statement):

    *B,BODY,CENTER,FONT,HTML,TITLE*

The more useful example below displays all of the links from this page to any other page.

    message tagarray(myPage,{href="},{"},¶)

See Also

- gettaglocation -- locates the first matching tag within some text.
- gettaglocations -- locates all matching tags within some text.
- settagdata -- changes the contents of a tag.
- setxtagvalue -- changes the contents of a tag.
- tagcount( -- 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( -- extracts the body of the specified tag (usually an HTML tag) in the text. See Tag Parsing for more information on HTML tags.
- tagend( -- returns the ending position of the specified tag (usually an HTML tag) in the text.
- tagnumber( -- checks to see if a specified position is inside of a tag (usually an HTML tag).
- tagparameter( -- extracts the value of a tag parameter embedded in some text, where the tag parameter takes the form *name=value*.
- tagstart( -- returns the starting position of the specified tag (usually an HTML tag) in the text.
- tagstrip( -- removes tags (usually HTML tags) from within a piece of text.
- xtag( -- generates an HTML/XML tag.
- xtagvalue( -- extracts the text from the first matching HTML or XML tag.

History

Version | Status | Notes
10.0 | No Change | Carried over from Panorama 6.0