ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / HTML file functions
  • Declaration
  • Properties specific to htmlNode variables
  • Creating a text node
  • WLanguage functions that use htmlNode variables
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
htmlNode (Variable type)
In french: htmlNoeud
The htmlNode type is used to define all the advanced characteristics of a node of an HTML document. You can define and change the characteristics of this node using different WLanguage properties.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
MonDocument is htmlDocument

// Récupère le document depuis le champ d'affichage HTML
MonDocument = HTM_Source.ValeurAffichée


// On veut récupérer uniquement les tarifs de livraison en points relais en fonction du poids
// On récupère les pays
// Dans le thead / 2ème TR / 3 premiers TD
sPays1, sPays2, sPays3 is string

// On récupère le tableau des headers
tabHeader is array of htmlNode = MonDocument.FindElementByTag("thead")

// Sur le premier élément, on prend le deuxième fils (le deuxième TR)
// Le premier fils de ce TR, c'est le TD du premier pays
// A l'intérieur du TD, il peut y avoir d'autre balises (span, p) pour gérer les styles
// Mais le contenu final est dedans, donc on peut récupérer le HTMLInterne du TD et 
// Le convertir "directement" en texte

sPays1 = HTMLToText(tabHeader[1].tr[2].td[1]..InnerHTML)
// Le second fils de ce TR, c'est le TD du second pays
sPays2 = HTMLToText(tabHeader[1].tr[2].td[2]..InnerHTML)
// Le troisième fils de ce TR, c'est le TD du troisième pays
sPays3 = HTMLToText(tabHeader[1].tr[2].td[3]..InnerHTML)

sPoids, sTarifPays1, sTarifsPays2, sTarifPays3 are strings

// Modifie les titres des colonnes de la table
TABLE_Tarifs.COL_Pays1.Libellé = sPays1
TABLE_Tarifs.COL_Pays2.Libellé = sPays2
TABLE_Tarifs.COL_Pays3.Libellé = sPays3

FOR i = 1 _TO_ 9

	// On récupère le poids et les tarifs par pays

	sPoids = MonDocument.html.body.div.div.table.tbody.tr[i].td[1]..Text
	sTarifPays1 = MonDocument.html.body.div.div.table.tbody.tr[i].td[3]..Text
	sTarifsPays2 = MonDocument.html.body.div.div.table.tbody.tr[i].td[4]..Text
	sTarifPays3 = MonDocument.html.body.div.div.table.tbody.tr[i].td[5]..Text

	TABLE_Tarifs.AjouteLigne(sPoids, sTarifPays1, sTarifsPays2, sTarifPays3)

END
Declaration

Declaring a node Hide the details

MyVariable is HtmlNode
To describe an HTML node, the name of the node can be specified with the TagName property.

Creating an HTML node Hide the details

MyVariable is HtmlNode (<Tag name>)
<Tag name>: Character string
Name of the node to create.
Properties

Properties specific to htmlNode variables

The following properties can be used to handle a node of an HTML document:
Property nameType usedEffect
AttributeArray of htmlAttributeAttributes of an htmlNodeElement node.
ChildNodeArray of htmlNode variablesChild node of an htmlNodeElement node.
CountIntegerNumber of elements with the same name.
This property is read-only.
ExistBoolean
  • True if the node exists in the document,
  • False otherwise.
This property is read-only.
IndexIntegerIndex of the node in its parent.
This property is read-only.
InnerHTMLCharacter stringHTML code of the sub-nodes in the current node.
OuterHTMLCharacter stringHTML code that includes the current node (including the sub-node).
This property is read-only.
ParenthtmlNode variableParent node, NULL if the node is the root.
This property is read-only.
TagNameCharacter stringName of the tag if the node is an htmlNodeElement node, empty string ("") otherwise.
TextCharacter stringContents of the node encoded in the current character set.
  • If the node is of type htmlNodeText, htmlNodeComment or htmlNodeCDATA, the property returns and modifies the node.
  • If the node is of type htmlNodeElement, the property returns the concatenation of the text of all subnodes.
When a value is assigned to the property, it empties the subnodes and replaces them with a text subnode containing that value.
TypeInteger constantType of node:
  • htmlComment node Comment node.
  • htmlNodeCDATA CDATA node (XHTML compatible).
  • htmlElementNode Element node, a tag in HTML.
  • htmlTextNode Text node.
Remarks
The following operators are available for a node of type htmlNodeElement:
  • Operator ".": The operator "." allows access to sub-elements by their tag name.
  • Operator ":": The ":" operator is used to access attributes by name.
  • Operator [ <indice> ]: This operator is used to access sibling sub-elements of the same name by their index.
  • Operator [ <nom> ]: This operator is used to access sub-elements by their tag name.
htmlNodeElement nodes can contain subnodes.
Looping through subnodes
  • "FOR EACH x OF NodeVariable" is used to loop through all the subnodes.
  • "FOR EACH x OF NodeVariable IN-DEPTH" is used to recursively loop through all the subnodes.
    Android This syntax is not available.

Creating a text node

A text node can be declared using one of the following syntaxes:
  • Implicit declaration:
    o is htmlNode
    o.Text = "A"
  • Explicit declaration:
    o is htmlNode
    o.Type = htmlNodeText
    o.Text = "A"

WLanguage functions that use htmlNode variables

Related Examples:
HTML types (HTMLDocument, HTMLNode, HTMLAttribute) Unit examples (WINDEV): HTML types (HTMLDocument, HTMLNode, HTMLAttribute)
[ + ] This example shows how to use the HTMLXxx WLanguage types (HTMLDocument, HTMLNode, HTMLAttribute)
WD HTML Export Training (WINDEV): WD HTML Export
[ + ] This example explains how to export data in HTML format with the WLanguage functions.
The following topics are presented in this example:
1/ the functions for managing the external files for generating the HTML file
2/ the operations performed on the HTML tags
3/ the generation of an HTML report
The generation of an HTML page is performed from the data found in a memory table.
By programming
The principle consists in generating a text file with a "HTM" extension. The WLanguage function named "fWrite" will be used.
This example easily writes the text strings by respecting the syntax of the HTML language.
Automatically
The principle consists in creating a report on table based on the memory table that was previously filled.
The printout is requested with an HTML output.
WD HTML Page Import Sample components (WINDEV): WD HTML Page Import
[ + ] This example explains how HTML pages can be imported with the WLanguage functions.
The following topics are presented in this example:
1/ how to import an object found on a Web site
2/ how to analyze an HTML file
Summary of the example supplied with WINDEV:
This example is used to save locally an HTML page found on a Web site.
This page is analyzed in order to import all its dependencies (images, applets, and so on). This example is not a Web grabber. It can only be used to download the pages one by one.
The principle used in this example can also be used to retrieve informations from pages whose format is recognized (example: daily retrieval of share values)
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help