XmlElement.AppendFromText (gb.xml)

Sub AppendFromText ( Data As String, Arguments As , ... )

This function parses the given XML Data, and adds all the found nodes to the end of the list of children of this element.

Data can contain the special strings &1, &2 and so on to substitute values from Arguments into the string, just like calling Subst$. This is done before Data is parsed.

This method is very useful and faster if you want to add a lot of static nodes (i.e. if they are always the same) to an element, without using thousand of lines of code with the standard DOM interface.

This method is a faster way to do :

Dim element As New XmlElement("foo")

element.AppendChildren(XmlElement.FromText(Data))

Even if this method is optimized, the needed ressources increases with node count, so beware if you use it in a loop !

Examples

Dim element As New XmlElement("foo")

Print element.Children.Count 'Shows 0

element.AppendFromText("<p>Hello world ! <br /> This is a sample of text, <strong>very long and very boring</strong></p><a href='nowhere'> Clock here to avoid it</a>")
element.AppendFromText("Report generated on &1. Department of &2.", Format$(Now(), gb.GeneralDate), "Gambas")
' ^ Report generated on 06/03/2018 12:00:00. Department of Gambas.

Print element.Children.Count ' shows 2: the <p>, the <a> and a text node

See also