Archive for décembre, 2009
first implementation
by admin on déc.19, 2009, under Non classé
Here is a first implementation of the XMLElement. This one is just a first test of instance creation.
It will evolv in the new few days.
//XMLElement constructor this.XMLElement = function XMLElement(parent, file){ // Don't know if Internet Explorer has to be managed. // Don't know yet how the parent element will be usefull because methods of the object are not calling it this.parent = parent; try{ xmlDoc=document.implementation.createDocument("","",null); } catch(e){ alert(e.message); return; } xmlDoc.async=false; xmlDoc.load(file); // All this methods declaration should be filled next. //This method must return the number of children of the interrogated node. this.getChildCount = function getChildCount(){ return this.childNodes.length; }; //This method must return the child at the given index. this.getChild = function getChild(index){ return this.childNodes[index]; }; this.getChild = function getChild(path){}; //This method must return all children as an XMLElement Array. this.getChildren = function getChildren(){}; this.getChildren = function getChildren(path){}; //Returns the content of an element. If there is no such content, null is returned. this.getContent = function getContent(){}; //Returns an integer attribute of the element. //If the default parameter is used and the attribute doesn't exist, the default value is returned. //When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. //Don't understand that one ... this.getIntAttribute = function getIntAttribute(name){}; this.getIntAttribute = function getIntAttribute(name, defaultValue){}; // Returns a float attribute of the element. //If the default parameter is used and the attribute doesn't exist, the default value is returned. //When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. this.getFloatAttribute = function getFloatAttribute(name){}; this.getFloatAttribute = function getFloatAttribute(name, defaultValue){}; //Returns a String attribute of the element. //If the default parameter is used and the attribute doesn't exist, the default value is returned. //When using the version of the method without the default parameter, if the attribute doesn't exist, the value 0 is returned. this.getStringAttribute = function getStringAttribute(name){}; this.getStringAttribute = function getStringAttribute(name, defaultValue){}; //Returns the name of the element this.getName = function getName(){}; return xmlDoc; };