responseXML has trailing garbage

B

björn lundin

Hi, I've got a (to me) strange error doing AJAX.
I get the followomg fault in Firebug,
and translated to english it says:
Xml parsing error : junk after document element Address .....
Row 1, column 110

If i alert responseText, it looks fine.
If i run with parameter GET_ONE_RECORD, it works fine,
with responseXML

Any ideas?


XML-tolkningsfel: skräp efter dokumentelement Adress:
http://tova/repowebgui/repoinfo.php?mode=table&action=GET_ONE_RECORD&name=bassign
Radnummer 1, Kolumn 119:
<sourcetext>&lt;?xml version='1.0' encoding='ISO-8859-1'?&gt;&lt;table
name='bassign' desc='desc of bassign' tablespace='space' clreq='1'/
&gt;&lt;column name='abc' type='1' len='4'/&gt;&lt;column name='dbc'
type='2' len='9'/&gt;&lt;column name='fbc' type='9' len='9'/
&gt;&lt;column name='gbc' type='9' len='9'/&gt;&lt;/table&gt;
----------------------------------------------------------------------------------------------------------------------
^</sourcetext>
</parsererror>





----------------
http://tova/repowebgui/repoinfo.php
<?php

if (isset($_GET['action'])) {
$action=$_GET['action'];
}

if (isset($_GET['mode'])) {
$mode=$_GET['mode'];
}

if (isset($_GET['name'])) {
$name=$_GET['name'];
}


header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
//A date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
switch ($mode) {
case "table":
switch ($action) {
case "GET_ALL_RECORDS":
echo "<tables>";
echo "<table name='bassign' desc='Inv asm'>beskrivning här?</
table>";
echo "<table name='bseq' desc='Inv transport seq'/>";
echo "<table name='xloc' desc='Locations'/>";
echo "<table name='xseq' desc='Transport Sequences'/>";
echo "</tables>";
exit;
break;
case "GET_ONE_RECORD":
echo "<table name='" . $name . "' desc='desc of " . $name .
"' tablespace='space' clreq='1'/>" ;
echo "<column name='abc' type='1' len='4'/>";
echo "<column name='dbc' type='2' len='9'/>";
echo "<column name='fbc' type='9' len='9'/>";
echo "<column name='gbc' type='9' len='9'/>";
echo "</table>";
exit;
break;
default:
echo "<not_implemented mode='$mode' action='$action'/>";
break;
}
break;
default:
echo "<not_implemented mode='$mode' action='$action'/>";
break;
}
?>

-----------------
function loadTableMetadata(tblName) {
var xmlhttp = xhr();
xmlhttp.open("GET","repoinfo.php?
mode=table&action=GET_ONE_RECORD&name="+tblName,false);
xmlhttp.send(null);
var xmlResponse = xmlhttp.responseXML;
alert(xmlResponse);
var tableElement = xmlResponse.getElementsByTagName("table")[0]; //
<--- FAILS
var txtTableName = document.getElementById("txtTableName");
var txtTableDesc = document.getElementById("txtTableDesc");
var txtTableTableSpace =
document.getElementById("txtTableTableSpace");
var chkTableClreq = document.getElementById("chkTableClreq");

txtTableName.value =
tableElement.attributes.getNamedItem("name").value;
txtTableDesc.value =
tableElement.attributes.getNamedItem("desc").value;
txtTableTableSpace.value =
tableElement.attributes.getNamedItem("tablespace").value;
chkTableClreq.value =
tableElement.attributes.getNamedItem("clreq").value;

xmlhttp = null;
xmlResponse = null;

}

I get this on ubuntu 11.04 as well as on mac os Snow Leopard...
 
B

Bjoern Hoehrmann

* björn lundin wrote in comp.lang.javascript:
Xml parsing error : junk after document element Address .....
echo "<table name='" . $name . "' desc='desc of " . $name .
"' tablespace='space' clreq='1'/>" ;
echo "<column name='abc' type='1' len='4'/>";
echo "<column name='dbc' type='2' len='9'/>";
echo "<column name='fbc' type='9' len='9'/>";
echo "<column name='gbc' type='9' len='9'/>";
echo "</table>";

You wrote <table .../> while you meant <table ...> without the slash.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top