JDOM_Element methods

 

JDOM_Element methods

 

Figure 26. The JDOM_Element metaclass

 

The following methods are provided by the JDOM_Element metaclass:

setAttribute (In pName : String, In pValue : String) ;

If the attribute named pName exists in the current element, this sets the value of the attribute to pValue.  If this is not the case, the attribute named pName is created under the current element with pValue as its value.

 

Note:      pValue must be a simple string and must not contain elements such as entity references. To create such an attribute, you must first create the attribute and then attached an entity reference to it, before adding it to the element using a setAttributenode.

 

setAttributeNode (Inout pAttribute : JDOM_Node) :

                      JDOM_Node ;

This adds a new attribute to the element.  If an attribute of the same name as pAttribute->getNodeName() already exists, it is simply replaced and returned.  Otherwise, this returns null.

 

removeAttribute (In pName : String) ;

This removes the attribute named pName from the current element.

 

removeAttributeNode (InOut pOldAttribute : JDOM_Node) :

                      JDOM_Node;

This removes pOldAttribute from the element's attributes and returns this same element.

 

getTagName() : String;

This returns the name of the current element.

 

getAttribute (In pName : String) : String;

This returns the value of the attribute named pName of the current element.  This is null if the attribute has no value defined or no default value.

 

getAttributeNode (In pName : String) : JDOM_Node;

This returns an attribute by its name or returns null if the attribute is not under the element.

 

getElementsByTagName(In pTagName : String,

                 Inout pElts [*] JDOM_Node);

This returns the elements named pTagName encountered from the current element onwards in the pElts list.

 

Note:      For optimization reasons, the set is not returned but is instead passed as the InOut parameter.  In this respect, this method differs from the standard DOM API.

 

Unlike the DOM API, the returned list is not dynamic, but is rather a copy of the tree at a given moment in time.