XMLNode.appendTo(xmlNode)

Appends an XMLNode at the end of children list of another. The following example shows how to append nodes created separately from the XML tree. In this case they are appended to the root element of the tree.

// ==================================================== // 6. How to create a separate node and append it to another. xmlDoc = XMLDocument() xmlNodeRoot = addRootFor(xmlDoc, tag : "invoice") display print(xmlDoc) xmlNode1 = createXMLNodeFor(xmlDoc, tag : "customer") xmlNode1.text = "Peter" xmlNode = appendTo(xmlNodeRoot, node : xmlNode1) xmlNode2 = createXMLNodeFor(xmlDoc, tag : "total") xmlNode2.text = "1210" xmlNode = appendTo(xmlNodeRoot, node : xmlNode2) display print(xmlDoc)

The example below, shows how a node can be copied and then appended to an existing node. xmlDoc = XMLDocument() initialize xmlDoc using content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><invoice></invoice>" xmlNode2.text = "May 26, 2005" xmlNode2 = addChildFor(xmlNode, tag : "customer") xmlNode2.text = "Peter" // ==================================================== // Adding a child Node to an existing node.. suppose the customer node has the billing address as a child xmlNode3 = addChildFor(xmlNode2, tag : "address") xmlNode3.text = "Park Ave. 2039 NY" // ==================================================== // Append a node to an existing one, suppose that the customer also has a delivery address, we'll build the // node separately and then we will append it to the customer node xmlNode4 = xmlNode3.copy xmlNode4.text = "St.Peter Blvd. 3920 CA" xmlNode5 = appendTo(xmlNode2, node : xmlNode4)

Arguments:

Name Type Description Mode
xmlNode Fuego.Xml.XMLNode node to append in