blog games developers documentation portfolio gallery

More in this category:

GetNodeAtPath()

To use this function you need to include the line
using SimpleXmlExtensions;
in your source code.

object GetNodeAtPath(string[] path)


This function is defined for Hashtable and for ArrayList and returns either a Hashtable, an ArrayList or the value stored at the given location (usually a string).

It moves down the hierarchy looking for nodes with the keys that correspond to the path and returns the first node it encounters that matches it.

When the path is not found, it returns NULL.

Example:
private object GetMaterialsFromCollada(string[] aPath) {
object materialsNode = colladaHashtable.GetNodeAtPath(new string[2] {"collada", "library_materials");

// the returned object can be of any type
// only Hashtables and ArrayLists can be converted to a nice readable JSON format
// so we have to test for the type first
if(materialsNode==null) {
Debug.Log("Nothing found");
} else if(selectedNode.GetType() == typeof(Hashtable)) {
Debug.Log("Found Hashtable (written as JSON): " + ((Hashtable)materialsNode).JsonString());
} else if(selectedNode.GetType() == typeof(ArrayList)) {
Debug.Log("Found ArrayList (written as JSON): " + ((ArrayList)materialsNode).JsonString());
} else {
Debug.Log("Found value: " + materialsNode);
}
return materialsNode;
}







follow us