N
NaReN
I'm just reading up on OO Javascript but I just can't seem it to work
Here's what my code looks like :
function initXML() {
var myXML = new xmlDocument("<items><item>Apple</item><item>orange</
item></items>");
myXML.getItems();
}
function xmlDocument( aString ){
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(aString, "text/xml");
return xmlDoc ;
}
xmlDocument.prototype.getItems(){
var items = xmlDoc.evaluate("//item",xmlDoc, null,
XPathResult.ANY_TYPE,null);
var thisItem = items.iterateNext();
while (thisItem) {
thisItem = items.iterateNext();
}
}
However, when I try it out in FireFox 2 and call initXML I get :
Error: myXML.getItems is not a function
The above given way of inheritance works fine for user-defined objects
but gets stuck whenever the constructor returns a system-defined
object..
Any idea what I'm doing wrong ?
Here's what my code looks like :
function initXML() {
var myXML = new xmlDocument("<items><item>Apple</item><item>orange</
item></items>");
myXML.getItems();
}
function xmlDocument( aString ){
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(aString, "text/xml");
return xmlDoc ;
}
xmlDocument.prototype.getItems(){
var items = xmlDoc.evaluate("//item",xmlDoc, null,
XPathResult.ANY_TYPE,null);
var thisItem = items.iterateNext();
while (thisItem) {
thisItem = items.iterateNext();
}
}
However, when I try it out in FireFox 2 and call initXML I get :
Error: myXML.getItems is not a function
The above given way of inheritance works fine for user-defined objects
but gets stuck whenever the constructor returns a system-defined
object..
Any idea what I'm doing wrong ?