The following tables provide a quick reference to the ways you can modify the contents of an XML document object. The sections that follow describe in detail how to modify XML contents.
Adding information to an element
Use the following techniques to add new information to an element:
Type |
Using a function |
Using an assignment statement |
---|---|---|
Attribute |
StructInsert(xmlElemPath.XmlAttributes, "key", "value") | xmlElemPath.XmlAttributes.key = "value" xmlElemPath.XmlAttributes["key"] = "value" |
Child element |
To append: ArrayAppend(xmlElempath.XmlChildren,newElem)To insert: ArrayInsertAt(xmlElempath.XmlChildren, position, newElem) |
To append: xmlElemPath.XmlChildren[i] = newElem xmlElemPath.newChildName = newElem(where |
Deleting information from an element
Use the following techniques to delete information from an element:
Type |
Using a function |
Using an assignment statement |
---|---|---|
Property |
StructDelete(xmlElemPath, propertyName) | xmlElemPath.propertyName="" |
Attribute |
All attributes: StructDelete(xmlElemPath, XmlAttributes)A specific attribute: StructDelete(xmlElemPath.XmlAttributes,"attributeName") |
Not available |
Child element |
All children of an element: StructDelete(xmlElemPath, "XmlChildren") or ArrayClear(xmlElemPath.XmlChildren)All children with a specific name: StructDelete(xmlElementpath,"elemName") ArrayClear(xmlElemPath.elemName)A specific child: ArrayDeleteAt(xmlElemPath.XmlChildren,position) ArrayDeleteAt(xmlElemPath.elemName,position) |
Not available |
Changing contents of an element
Use the following techniques to change the contents of an element:
Type |
Using a function |
Using an assignment statement |
---|---|---|
Property |
StructUpdate(xmlElemPath,"propert yName", "value") | xmlElemPath.propertyName = "value" xmlElemPath["propertyName"] = "value" |
Attribute |
StructUpdate(xmlElemPath.XmlAttri butes,"attributeName", "value") | xmlElemPath.XmlAttributes. attributeName="value" xmlElemPath.XmlAttributes ["attributeName"] = "value" |
Child element (replace) |
ArraySet(xmlElemPath.XmlChildren,
index,index, newElement)
(use the same value for both index entries to change one element) |
Replace first or only child named elementName: parentElemPath.elementName = newElement parentElemPath["elementName"] = newElementReplace a specific child named elementName: parentElemPath.elementName [index] = newElementor parentElemPath["elementName"] [index] = newElement |