Namespaces and Attributes

With a namespace aware parser, attributes are accessed and manipulated with a special set of namespace sensitive methods.

getAttributeNS

The getAttributeNS method allows you to get the value of an attribute, by passing in the namespace URI and local name. If the attribute does not exist, an empty string is returned.

$myElement->getAttributeNS('http://www.engageinteractive.com/tests', 'score');

setAttributeNS

The setAttributeNS method allows you to set the value of an existing attribute. A new attribute is created if one does not already exist. You must pass in the namespace URI and a qualified name along with the attribute value.

$myElement->setAttributeNS('http://www.engageinteractive.com/tests', 'ei:score', '95');

removeAttributeNS

The removeAttributeNS method will remove the specified attribute if it exists. You must pass in the namespace URI and local name.

$myElement->removeAttributeNS('http://www.engageinteractive.com/tests', 'score');

hasAttributeNS

The hasAttributeNS method returns true if the specified attribute exists. You must pass in the namespace URI and local name.

$doesExist = $myElement->hasAttributeNS('http://www.engageinteractive.com/tests', 'score');

getAttributeNodeNS

The getAttributeNodeNS method will return a reference to the specified attribute node, or null if the node does not exist. You must pass in the namespace URI and local name.

$myAttribute =& $myElement->getAttributeNodeNS('http://www.engageinteractive.com/tests', 'score');

setAttributeNodeNS

The setAttributeNodeNS method will append an attribute node to the attribute list of an element.

$myAttribute =& $xmldoc->createAttributeNS('http://www.engageinteractive.com/tests', 'ei:score');
$myElement->setAttributeNode($myAttribute);


Documentation generated by ClassyDoc, using the DOMIT! and SAXY parsers.
Please visit Engage Interactive to download free copies.