[Project_owners] nsIXMLHttpRequest woes

Eric H. Jung eric.jung at yahoo.com
Thu May 18 18:39:16 EDT 2006


The following works. It's interesting that none of the JS DOM
"shortcuts" work at this point of startup ("xpcom-startup"). For
instance, [i] must be .getNamedItem(i), .value must be .nodeValue, etc.

Thanks for everyone's help and suggestions.


var req = CC["@mozilla.org/xmlextras/xmlhttprequest;1"].
  createInstance(CI.nsIXMLHttpRequest);
req.open("GET", "chrome://foxyproxy/content/strings.xml", false);
req.send(null);
var e = req.responseXML.getElementsByTagName("i18n");
this._entities = new Array();      
for (var i=0; i<e.length; i++)  {
  var attrs = e.item(i).attributes;
  this._entities[attrs.getNamedItem("id").nodeValue] =
    attrs.getNamedItem("value").nodeValue;
}


--- Nickolay Ponomarev <asqueella at gmail.com> wrote:

> On 5/19/06, Eric H. Jung <grimholtz at yahoo.com> wrote:
> >
> >
> > --- Nickolay Ponomarev <asqueella at gmail.com> wrote:
> >
> > > On 5/19/06, Alex Vincent <ajvincent at gmail.com> wrote:
> > > > > var req =
> > > Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
> > > > >   .createInstance(Components.interfaces.nsIXMLHttpRequest);
> > > > >
> > > > > req.open("GET", "chrome://foxyproxy/content/strings.xul",
> false);
> > > >
> > > > XMLHttpRequest doesn't work for chrome URL's (HTTP and chrome
> are
> > > > different protocols entirely).  Personally, I recommend you
> look
> > > into
> > > > DOMParser and the ChromeFile interface I wrote for jslib.
> > > >
> > > Yes it does. It's neither restricted to XML nor to HTTP.
> > >
> > > Eric: does e.item(i) work?
> > >
> >
> > Hi Nickolay,
> >
> > Good thinking! (I know item() is from the W3C DOM spec).
> Unfortunately,
> > no, I get the same problem--undefined. What is strange is that
> > list.length is 35 (which is the correct number), so I know the
> parser
> > is working to some extent...
> >
> What if you serialize that document using the XMLSerializer?
> 
> Nickolay
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
> 


Use Your PC To Find a Cure for Cancerhttp://members.ud.com/services/teams/team.htm?id=68C9E079-8285-495F-8598-D73352CC7075And Join Team Lulu


More information about the Project_owners mailing list