Robeast Posted May 31, 2007 Share Posted May 31, 2007 I am having troubles trying to extract information from an XML document created by a PHP page. The php page can be viewed <a href="http://nyagwaimethods.com/testpage.php">here</a>. It is returned and everything is working until I try to extract the information. Here is the function I am using to try and extract the information from the XML document. function handleServerResponse() { // retrieve the server's response packaged as an XML DOM object var xmlResponse = xmlHttp.responseXML; // catching potential errors with IE and Opera if (!xmlResponse || !xmlResponse.documentElement) throw("Invalid XML structure:\n" + xmlHttp.responseText); // catching potential errors with Firefox var rootNodeName = xmlResponse.documentElement.nodeName; if (rootNodeName == "parsererror") throw("Invalid XML structure:\n" + xmlHttp.responseText); // getting the root element (the document element) xmlRoot = xmlResponse.documentElement; // testing that we received the XML document we expect if (rootNodeName != "memberInfo" || !xmlRoot.firstChild) throw("Invalid XML structure:\n" + xmlHttp.responseText); // Trying to get the realName node information var name = xmlResponse.documentElement.firstChild.nodeName; var realName = xmlResponse.documentElement.firstChild.nodeValue; alert("The Node Name is: " + name + " and the value is: " + realName); } I am trying to get the information from the realName node. Here is the alert output I get "The Node Name is #text and the value is:" When I print out the rootNodeName variable, memberinfo is outputted, so I know it is getting some information from the XML document. I am a newbie to the whole XML thing so any help is greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/53761-problem-with-return-xml-document/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.