-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
responseXML not being set? #8
Comments
Hey, while there's really only one XMLHttpRequest project for Node.js, there are many XML parsers with different plusses and minuses, with two different XML-DOM-compliant implementations out there. Well, the second is almost-compliant, but intentionally drops a few infrequently-used features for faster speed. Note: I'm in no way related to either of those projects, and the data interchange format of choice at the startup I work at is JSON-RPC, so I haven't used either, just going off of their respective descriptions. This library is pretty much a standalone, only-core-library-dependencies project, which is probably why its that way right now. If you want the interface to be identical (so the code can run both client and server), forking the project is probably your best bet. |
node-XMLHttpRequest doesn't currently support parsing XML. As David mentioned this is because there is no native XML parsing in node and I haven't really thought about requiring external libraries. Additionally you're relying on getElementsByTagName which will require an XML library that supports DOM functions. |
Hello, I implemented responseXML in my fork of node-XMLHttpRequest
I implemented it within an exception handler so node-XMLHttpRequest I hope Dan (driverdan) will add my patch into the mainstream. The implementation : To use this feature you need to : var sys = require('util'); Best Regards, |
…thname_when_loading_from_local_filesystem Unescape pathname from url when loading from local filesystem
Hello,
I am trying to use node-XMLHttpRequest to make AJAX calls from JavaScript code running in node.js. The JavaScript code calls a simple PHP-based server app, which returns some XML (see below). The code works fine when running in a browser, but it does not work properly when runing in node.js using node-XMLHttpRequest. The call to the server completes, but there does not seem to be any data in responseXML. Instead, node.js gives me the error:
TypeError: Object has no method 'getElementsByTagName'
The complete text returned by the server is contained in http.responseText. When/how can that text be parsed into XML so that I can grab the "timenow" field? Looking at the code for node-XMLHttpRequest, it looks like only the responseText variable is filled (on line 212) when a "data" response is received. I see almost no references to the responseXML variable.
Is there some other code required for filling/scanning the responseXML variable, which still has to be implemented in node-XMLHttpRequest? Or am I not calling the function properly to receive data in XML format?
The code is below. Thanks for any tips or pointers.
--IO
CLIENT CODE (JS):
var http = new XMLHttpRequest();
function getServerTime() {
var myurl = 'http://kundry/qrate.php';
myRand = parseInt(Math.random() * 999999999999999);
var modurl = myurl+"?rand="+myRand;
http.open("get", modurl, true);
http.onreadystatechange = useHttpResponse;
http.send(null);
}
function useHttpResponse() {
if (http.readyState == 4) {
if (http.status == 200) {
var timeValue = http.responseXML.getElementsByTagName("timenow")[0];
console.log("timenow="+timeValue.childNodes[0].nodeValue);
}
}
}
The text was updated successfully, but these errors were encountered: