Map HTML

Verb: mapHTML

Maps data of an HTML text based on parameters of an XPath expression, saving it to variables.

Syntax

mapHTML --html(String) --outputtype(OutputHtmlType) [--removenamespaces(Boolean)] --mappings(String)

Inputs

Script Designer Required AcceptedTypes Description
--html HTML Required Text Text in HTML format to be mapped.
--outputtype Output Type Required OutputHtmlType Filter to fetch and return the properties of HTML elements and/or their value:
  • Value: Returns only the value of each mapped element;
  • InnerHtml: Returns only the inner content of the mapped element;
  • OuterHtml: Returns both the mapped element and its inner content.
  • --removenamespaces Remove Namespaces Optional Boolean When enabled, removes the namespace contained in the HTML text, so that XPATH mapping runs more simply.
    --mappings Mappings Required Text Maps the HTML text based on an XPATH expression extracted from the same HTML text:
  • In the "Parameter" field, enter the XPATH of the element to be mapped;
  • In the "Value" field, enter a variable of "Text" type that will receive the content of the mapped element.
  • Example

    The Map HTML command gets text from an HTML from the mapped HTML element, with the Remove Namespaces parameter disabled and Output Type set to InnerHtml. The Log Message command records the content obtained.

    defVar --name html --type String --value "<!DOCTYPE html>\r\n<html>\r\n    <head>\r\n        <title>HTML Example</title>\r\n    </head>\r\n    <body>\r\nHello World!\r\n    </body>\r\n</html>"
    defVar --name htmlText --type String
    mapHTML --html "${html}" --outputtype "InnerHtml" --removenamespaces  --mappings "html==${htmlText}"
    logMessage --message "html: ${html}\r\n\r\n" --type "Info"
    // Show in the console the HTML text according to the mapping.
    

    See Also

  • Convert HTML to Text
  • Get HTML Tables
  • HTML to Markdown