THtmlNode() > Overloaded operators |
Opens a new HTML node
+ <cTagName>
The overloaded plus operator accepts a THtmlNode object as left operand, and a character string beginning with a valid HTML tag name as right operand. If the right operand does not start with a valid HTML tag name, or if the left operand is an HTML node that cannot have child nodes, a runtime error occurs. Otherwise, a new THtmlNode object is added as child node to the self object and returned. For example:
oDoc := THtmlDocument():new() oNode := oDoc:body + "h1" // opening tag ? oNode:htmlTagName // result: h1 oNode:text := "Heading" oNode := oNode - "h1" // closing tag ? oNode:htmlTagName // result: body ? oDoc:body:toString() ** output // <body> // <h1>Heading</h1> // </body>
The right operand may include HTML attributes valid for the HTML tag. In this case, a new HTML node with attributes is created and returned. For example:
oDoc := THtmlDocument():new() oNode := oDoc:body + "table border=0 cellspacing=0" oNode := oNode + "tr" oNode := oNode + "td nowrap" oNode:text := "Table cell content" ? oDoc:body:toString() ** output // <body> // <table border=0 cellspacing=0> // <tr> // <td nowrap>Table cell content // </table> // </body>
http://www.xHarbour.com