926 new features of WINDEV 26, WEBDEV 26 and WINDEV Mobile 26

isting or new HTML documents. The native htmlDocument type is used to manage the entire HTML document. The native htmlNode type is used to manage a node of the HTML tree: a table, an Input field, a Meta tag... The htmlNode type offers many properties to manage each tag: • tag name • attribute • child element • sibling element • parent element • index • ... Example of access to a node of the HTML tree: Document is htmlDocument [...] Document . body : color = "blue" Benefit provided by this new feature of version 26: Your texts are always in style 020 N e w f e a t u r e W D W B WM SEARCH FOR ELEMENTS IN THE HTML DOCUMENT 2 new WLanguage functions allow you to search for elements in the entire HTML document: HTMLFindElementById and HTMLFindElementByName . These functions return an htmlNode variable, which can be used to perform all the desired processes. Benefit provided by this new feature of version 26: Useful functions 021 N e w f e a t u r e W D W B WM CODE EXAMPLES HTML programming in WLanguage is very powerful in version 26. Here are some examples of code used to read HTML: • Get a company's turnover on a website // Get the company's turnover // from the HTML file used to display data in table HTMLDoc is htmlDocument HTMLDoc = HTMLOpen ( "https://site.com/page.html " , fromURL ) FOR Year = 2010 TO 2020 element is htmlNode = HTMLDoc . FindByID ( "TO_" + Year ) ArrayAddLine ( TABLE_TO , Year , element . value ) END • Analyze an HTML page to retrieve an invoice // Get the invoice URL from the HTML file // to download the invoice HTMLDoc is htmlDocument = HTMLOpen ( "MyFile.html" , fromFile ) element is htmlDocument = HTMLDoc . FindByID ( "Invoice_092020" ) InvoiceURL is string = element . attributes [ "href" ] HTTPRequest ( InvoiceURL ) • Browse through an HTML table // Browse through table rows with ID czZ4 in the HTML document HTMLDoc is htmlDocument = HTMLOpen ( "MyFile.html" , fromFile ) table is htmlNode = HTMLDoc . FindByID ( "czZ4" ) FOR EACH Row DE table.tbody //Process END • Get the favicon of an HTML page // Get the URL of the page logo IMG_logo = HTMLDoc . head . querySelector (' link[rel*="icon"] '). href Here is an example of an HTML code generation program, which, based on a template, builds an HTML page to write reviews on a selection of products from a database: // Create survey // For new products, ask the opinion of the customers // "Base of survey" html document HTMLDoc is htmlDocument = HTMLOpen ( SurveyTemplate , fromString ) // Set position on <table> TheTable is htmlNode <- HTMLDoc . FindByID ( "TheTable" ) // Get "template" row (which will be deleted) TemplateRow is htmlNode = TheTable . TR DeleteAll ( TheTable ) // For each new product FOR EACH Product WHERE New = True // Create a survey row // with a caption: "PRODUCTNAME is a new product." // and an edit control already present in the template row ARow is htmlNode = TemplateRow ARow . TD . label .. Text = "Your opinion about" + Product . ProdDesc // Add row to the HTML document Add ( TheTable , ARow ) END // Save page HTMLSave ( HTMLDoc , "survey.html" , HTMLDefaultDocument ) Benefit provided by this new feature of version 26: Easily-customizable code 9 WINDEV 26 WEBDEV 26 WINDEV Mobile 26 New features

RkJQdWJsaXNoZXIy NDQ0OA==