error at ?xml version="1.0"

wxdqz

New Member
herm, i went to that page, and tried the example. //disclaimer, i'm new at this =p
I get an error in my xml code. I'll just provide the code.

I was wondering if i need to add something to my server so it will run xml. I don't know much about the server, as i've been given step by step instructions on how to set it up, and how to add the security i've put on it.

I am also wondering if i need the first line, i have it commented out atm, because it wasn't in the original tutorial.

the tutorial didn't tell me to put the functions inside script tags for java, but i've tried that and it still didn't work. It always gives me the parsing error when it hits xml.


this is register.php

//res.setContentType("text/xml"); //heard i should have this, but don't know?????

var req;

function loadXMLDoc(url)
{
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}

<input id="username" name="username" type="text" onblur="checkName(this.value,'') "/>
<span class-"hidden" id="nameCheckFailed">
This name is in use, please try another.
</span>

span.hidden
{
display: none;
}
span.error
{
display: inline;
color: black;
background-color: pink;
}

function checkName(input,response)
{
if (response != '')
{
//Response move
message = document.getElementById('nameCheckFailed');
if (response == '1')
{
message.className = 'error';
}
else
{
message.className = 'hudden';
}
}
else
{
//Input mode
url = 'http://localhost/newic/checkUserName.php?q=' + input;
loadXMLDoc(url);
}
}

<?xml

version="1.0" //error here is Parse error: parse error in c:\apache\htdocs\newic\register.php on line 43


encoding="UTF-8"
standalone="yes"?>
<response>
<method>checkName</method>
<result>1</result>
</response>

function processReqChange()
{
//online if req shows "complete"
if (req.readyState == 4)
{
//only if "OK"
if (req.status == 200)
{
//...processing statements go here...
response = req.responseXML.documentElement;

method = response.getElementsByTagName('method')[0].firstChild.data;

result = response.getElementsByTagName('result')[0].firstChild.data;

eval(method + '{\'\',result)');
}
else
{
alert("There was a problem retrieving the SM data:\n" + req.statusText);
}
}
}


this is checkUserName.php

<?php
header('Content-Type: text/xml');

function nameInUse($q)
{
if (isset($q))
{
//test if username stored in $q is taken yet
switch(strtolower($q))
{
case 'drew' :
return '1';
break;
case 'fred' :
return '1';
break;
default:
return '0';
}
}
else
{
return '0';
}
}
?>

<?php echo '<?xml version"1.0" encoding="UTF-8" standalone="yes"?>'; ?>
<response>
<method>checkName</method>
<result><?php
echo nameInUse($_GET['q']) ?>
</result>
</response>


i know thats alot to look through, but i hope someone can help. As long as i can get something working i can play with it to do whatever i want, but i need something working first =/

I've been trying to get help for a while, and told to post this question in a differnt forum alot, so any help would be great(that would also be why you may see this in a few differnt forums)
 
Back
Top