XML Element Accessors

These functions provide access to elements represented by property sets. The following information presents the parameter for this function.

XPSGetTagName()

Retrieves the tag name of an XML element.

Syntax

XPSGetTagName (xmlPropSet)

Parameter Description

xmlPropSet

The output property set.

Returns

String. If xmlPropSet is null, XPSGetTagName returns null.

XPSSetTagName()

This function sets the tag name of an XML element. The following table presents the parameters for this function.

Syntax

XPSSetTagName (xmlPropSet, tagName)

Parameter Description

xmlPropSet

The property set.

tagName

The name you want to supply as the current element name in the XML document.

Returns

String

XPSGetTextValue()

This function returns the text value of an XML element as a string. The following table presents the parameters for this function.

Syntax

XPSGetTextValue (xmlPropSet [, defaultIfNull [, defaultIfEmpty]])

Parameter Description

xmlPropSet

The output property set.

defaultIfNull

Specify a value to override the null default value that results if xmlPropSet is null.

defaultIfEmpty

Specify a value to override an empty string ("") contained in xmlPropSet.

Returns

String or null

Usage

If xmlPropSet is null then null is returned. You can use the optional defaultIfNull and defaultIfEmpty arguments to override null and empty string ("") return values. An element’s text value is the text between an XML element's start and end tags, excluding child elements.

XPSSetTextValue()

This function sets the text value of an XML element. The following table presents the parameters for this function.

Syntax

XPSSetTextValue (xmlPropSet, text)

Parameter Description

xmlPropSet

The property set.

text

A string you want inserted between start and end tags of an XML element.

Returns

Not applicable

Usage

The text argument should be a string. An element’s text value is the text between the element’s start and end tags, excluding child elements.

XPSGetAttribute()

This function retrieves an element’s attribute of the given name and returns it as a string. The following table presents the parameters for this function.

Syntax

XPSGetAttribute (xmlPropSet, name [, defaultIfNull [, defaultIfEmpty]])

Parameter Description

xmlPropSet

The output property set.

name

The name you want to supply as the root element name in the XML document.

defaultIfNull

Specify a value to override the null default value that results if xmlPropSet is null.

defaultIfEmpty

Specify a value to override an empty string ("") contained in xmlPropSet.

Returns

String

Usage

A null value is returned if xmlPropSet is null or the element does not have the named attribute. The optional defaultIfNull and defaultIfEmpty arguments can be used to override null and empty string ("") return values.

XPSSetAttribute()

This function sets an element attribute value. The following table presents the parameters for this function.

Syntax

XPSSetAttribute (xmlPropSet, name, value)

Parameter Description

xmlPropSet

The output property set.

name

Attribute name.

value

String value you want to supply as the attribute value.

Returns

String

Usage

No action is taken if any of the arguments are null.

XPSGetChildCount()

This function returns the number of children of an element. The following table presents the parameter for this function.

Syntax

XPSGetChildCount(xmlPropSet)

Parameter Description

xmlPropSet

The property set.

Returns

Number

Usage

All children of an element are also elements.

XPSGetChild()

This function returns the nth child element as specified by the index. The following table presents the parameters for this function.

Syntax

XPSGetChild(xmlPropSet, index)

Parameter Description

xmlPropSet

The property set.

index

Number, starting at zero, of child elements of another element in an XML document.

Returns

Property set

Usage

Child elements are specified using a zero-based index. A value of null is returned if the index is invalid.

XPSFindChild()

This function returns the first child element with the tagName. The following table presents the parameters for this function.

Syntax

XPSFindChild (xmlPropSet, tagName)

Parameter Description

xmlPropSet

The property set.

tagName

An XML element tag that signifies the first child element of another XML element.

Returns

Property set.

Usage

A value of null is returned if there is no child with the specified tag name.

XPSAddChild()

This function creates a new child element with the tagName and appends it to the list of xmlPropSet’s children. The following table presents the parameters for this function.

Syntax

XPSAddChild (xmlPropSet, tagName [, textValue])

Parameter Description

xmlPropSet

The property set.

tagName

The name you want to give to the new child element.

textValue

Optional. Sets the text value of the new element.

Returns

Property set