AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos HTML
  • Declaration
  • Properties specific to htmlNode variables
  • Creating a text node
  • WLanguage functions that use htmlNode variables
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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.
Ejemplo
MyDocument is htmlDocument
 
// Retrieves the document from the HTML Display control
MyDocument = HTM_Source.DisplayedValue
 
 
// Get delivery costs when choosing pickup points depending on the weight
// Get the countries
// In thead / 2nd TR / 3 first TD
sCountry1, sCountry2, sCountry3 is string
 
// Get array of headers
arrHeader is array of htmlNode = MyDocument.FindElementByTag("thead")
 
// On the first element, take the second child (second TR)
// The first child of this TR is the TD of the first country
// Inside the TD, there can be other tags (span, p) to manage styles
// But the final content is in there, so we can retrieve the InnerHTML from the TD, and
// Convert it "directly" to text
 
sCountry1 = HTMLToText(arrHeader[1].tr[2].td[1]..InnerHTML)
// The second child of this TR, is the TD of the second country
sCountry2 = HTMLToText(arrHeader[1].tr[2].td[2]..InnerHTML)
// The third child of this TR is the TD of the third country
sCountry3 = HTMLToText(arrHeader[1].tr[2].td[3]..InnerHTML)
 
sWeight, sPricingCountry1, sPricingCountry2, sPricingCountry3 are strings
 
// Modifies the table column titles
TABLE_Pricing.COL_Country1.Caption = sCountry1
TABLE_Pricing.COL_Country2.Caption = sCountry2
TABLE_Pricing.COL_Country3.Caption = sCountry3
 
FOR i = 1 _TO_ 9
 
// Get the weight and prices per country
 
sWeight = MyDocument.html.body.div.div.table.tbody.tr[i].td[1]..Text
sPricingCountry1 = MyDocument.html.body.div.div.table.tbody.tr[i].td[3]..Text
sPricingCountry2 = MyDocument.html.body.div.div.table.tbody.tr[i].td[4]..Text
sPricingCountry3 = MyDocument.html.body.div.div.table.tbody.tr[i].td[5]..Text
 
TABLE_Pricing.AddLine(sWeight, sPricingCountry1, sPricingCountry2, sPricingCountry3)
 
END
Declaration

Declaring a node Ocultar los detalles

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

Creating an HTML node Ocultar los detalles

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

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.
Observaciones
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.

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

Versión mínima requerida
  • Versión 26
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local