[Project_owners] nsIXMLHttpRequest woes

Eric H. Jung eric.jung at yahoo.com
Thu May 18 14:43:59 EDT 2006


Hi,

The following code executes in an XPCOM JS component in the context of
the "xpcom-startup" topic:

var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
  .createInstance(Components.interfaces.nsIXMLHttpRequest);

req.open("GET", "chrome://foxyproxy/content/strings.xul", false);
req.send(null);
this._entities = new Array();
var e = req.responseXML.getElementsByTagName("i18n");
dump("length==" + e.length + "\n");
for (var i=0; i<e.length; i++)  {
  dump("i=="+i+"\n");
  dump("e[i]==" + e[i] + "\n");
  this._entities[e[i].getAttribute("id")] = e[i].getAttribute("value");
}

It outputs the following to stdout:
  length==35
  i==0
  e[i]==undefined

I'm confused why e[i] == undefined? If I run this exact code in Ted's
Javascript Shell (default context, not browser.xul), it works just
fine.

Can anyone help? I'm stumped.

Thank you,
Eric Jung



More information about the Project_owners mailing list