Jump to content

Problem with return XML document


Robeast

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.