XML document object management reference

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.

Note: If your XML object is case sensitive, you cannot use dot notation to reference an element or attribute name. Use the name in associative array (bracket) notation, or a reference that does not use the case-sensitive name (such as xmlChildren[1]) instead.

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 newChildName must be the same as newElem.XmlName and cannot be an indexed name such as name[3])

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,
"propertyName", "value")
xmlElemPath.propertyName =
   "value"

xmlElemPath["propertyName"] =
   "value"

Attribute

StructUpdate(xmlElemPath.XmlAttributes,
"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"]
   = newElement

Replace a specific child named elementName:

parentElemPath.elementName
   [index] = newElement

or

parentElemPath["elementName"]
   [index] = newElement

View comments in LiveDocs