DOM guide: Working with elements
daeElement is the base class for all of the COLLADA Object Model classes. The daeElement class uses the Reflective Object System (ROS) to provide considerable functionality without the need to use the generated subclass.
There are three different approaches to finding which type of element a daeElement is.
The easiest is with the daeElement::getElementType method which returns an enumerated value respresenting the type of the element. The values returned by this function can be found in the dom/domTypes.h header.
The daeElement::getTypeName method returns a daeString of the type name. You can compare this string with the constant strings defined in dom/domConstants.h to check for type.
The last way is by comparing _meta. The _meta is a pointer to a daeMetaElement which is the class that contains all of the ROS information for an element type. By doing a pointer comparison on daeElement::getMeta and the generated class's static dom*::_Meta it is possible to find the element type. This is the approach that the daeSafeCast method uses to ensure type safety.
The daeSafeCast and daeElement::getElementType are rather new additions to the COLLADA DOM. When looking at older source code using the DOM expect to see the older methods used frequently for type checking.
Accessing Element Data
The easier way to access element data is to cast the daeElement to it's strongly typed subclass. At times, it may not be possible to do the cast or it is more convenient not to cast. The daeElement class provides methods to access and manipulate the data directly for such a situation.
daeElement provides access to the document it belongs to with the getDocument method. The getDocumentURI method is a helper method is all you need is the name of the document that the element belongs to.
daeElement::getParentElement returns the parent element which allows you to traverse up the tree to the root. If daeElement::getParentElement returns NULL the element is the root of the tree. If the element belongs to a document then it is safe to assume the element is a domCOLLADA element.
daeElement::getChildren populates an array with the children of an element. This allows you to iterate over all of the children of an element and traverse down the element hierarchy. This array will be ordered the same as it would be if the element were written out to a COLLADA instance Document. This array will be the same as the _contents array, if an element's type has a _contents array.