ShahriarK 0 Newbie Poster

Hi every body

I am new in AJAX. My server side language is ASP and I created the XML. At getting response i get this error "Only one top level element is allowed in an XML document."

Here is my created XML "

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
               <GoodForSell>
        <Good>
            <GoodCode>1</GoodCode>
            <GoodName>Resin6070</GoodName>
            <GoodPrice>4600000</GoodPrice>
            <GoodQuantity>150</GoodQuantity>
        </Good>
        <Good>
            <GoodCode>2</GoodCode>
            <GoodName>Resin 1020 </GoodName>
            <GoodPrice>5000000</GoodPrice>
            <GoodQuantity>100</GoodQuantity>
        </Good>
        <Good>
            <GoodCode>3</GoodCode>
            <GoodName>Resin 5020</GoodName>
            <GoodPrice>6000000</GoodPrice>
            <GoodQuantity>10</GoodQuantity>
        </Good>
        <Good>
            <GoodCode>5</GoodCode>
            <GoodName>Resin2010</GoodName>
            <GoodPrice>5000000</GoodPrice>
            <GoodQuantity>30</GoodQuantity>
        </Good>
                  </GoodForSell>

And here is my client side JAVA script Code

<script language ="javascript" type="text/javascript" >

    var XHRObject = false ;
    function getHttpObject()
    {

        var xmlHttp=null;

        if (window.XMLHttpRequest)
        {
            XHRObject = new  XMLHttpRequest();

        }
        else if (window.ActiveXObeject)
        {

                 XHRObject=new ActiveXObject("Microsoft.XMLHTTP");
         }  

         if (!XHRObject && typeof XMLHttpRequest != 'undefined')
          {

            try {
                XHRObject = new XMLHttpRequest();
                } catch (e) 
                    {
                        alert("!@!@!@!@!@");
                        XHRObject = false;
                    }
                }
    }


    //-----------------------------------------------------------------------
    function GetData()
    {
        var i
        var errorCode = 0 ;
        errorCode = XHRObject.responseXML.parseError.reason; 
        if (XHRObject.readyState == 4 && XHRObject.status == 200 )
        {   
            if (XHRObject.responseText.indexOf('invalid') == -1) 
            {
              try {
                [COLOR="red"]var serverResponse = XHRObject.responseXML ;
                alert (" errorcode    " + errorCode);
                document.write (errorCode);}
                catch (e){alert ("catch errorcode  " + errorCode);}[/COLOR]
                alert(" serverResponse " + serverResponse);
            }    
            var Row = serverResponse.getElementsByTagName("Good");
            var RowCreatePlace = document.getElementById ("GoodList");
            RowCreatePlace.innerHTML = "" ;
            alert(Row.length );
            for ( i=0 ; i < Row.length ; i++)
            {
                if (window.XMLHttpRequest)
                {
                    RowCreatePlace.innerHTML += "<table  border='1' width='50%'  height='32'><td  width = '10%' >" + Row[i].attributes.getNamedItem('GoodPrice').nodeValue; + "</td>";
                    RowCreatePlace.innerHTML += "<td  width = '70%' >" + Row[i].attributes.getNamedItem('GoodName').nodeValue; + "</td>"; 
                    RowCreatePlace.innerHTML += "<td  width = '20%' ><input type='checkbox' name='chk" + Row[i].attributes.getNamedItem('GoodCode').nodeValue; + " value= " + Row[i].attributes.getNamedItem('GoodCode').nodeValue;+ "></td></table>";
                    alert ('injam');            
                }
                else if (window.ActiveXObeject)
                {
                }   
            }  
        }
    }

    function Button_Click()
    {
        getHttpObject();
        XHRObject.open("GET","GoodsToSell.aspx",true);
        XHRObject.onreadystatechange = GetData;
        XHRObject.send(null);

    }

</script>

I don't know what is wrong with my created XML

Please help me
thank you and best regards