Home All Groups Group Topic Archive Search About

root element is missing

Author
25 Jan 2006 10:09 AM
sonu
i used the following code at client side:
function btn_send.onclick()
{
   // create ADO-stream Object
   var ado_stream = new ActiveXObject("ADODB.Stream");


   // create XML document with default header and primary node
   var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
   xml_dom.loadXML('<?xml version="1.0" ?> <root/>');
   // specify namespaces datatypes
   xml_dom.documentElement.setAttribute("xmlns:dt",
"urn:schemas-microsoft-com:datatypes");


   // create a new node and set binary content
   var l_node1 = xml_dom.createElement("file1");
   l_node1.dataType = "bin.base64";
   // open stream object and read source file
   ado_stream.Type = 1;  // 1=adTypeBinary
   ado_stream.Open();
   ado_stream.LoadFromFile("c:\\tmp\\myfile.doc");
   // store file content into XML node
   l_node1.nodeTypedValue = ado_stream.Read(-1); // -1=adReadAll
   ado_stream.Close();
   xml_dom.documentElement.appendChild(l_node1);


   // we can create more XML nodes for multiple file upload


   // send XML documento to Web server
   var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   xmlhttp.open("POST","./file_recieve.asp",false);
   xmlhttp.send(xml_dom);
   // show server message in message-area
   div_message.innerHTML = xmlhttp.ResponseText;



}


and wrote following code at server side in asp.net
dim xml as new XMLDocument()
xml.load(Request.InputStream)

but i m gettin error as :
root element is missing

Author
26 Jan 2006 8:38 AM
Frans Bouma [C# MVP]
sonu wrote:

Show quote
> i used the following code at client side:
> function btn_send.onclick()
> {
>    // create ADO-stream Object
>    var ado_stream = new ActiveXObject("ADODB.Stream");
>
>
>    // create XML document with default header and primary node
>    var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
>    xml_dom.loadXML('<?xml version="1.0" ?> <root/>');
>    // specify namespaces datatypes
>    xml_dom.documentElement.setAttribute("xmlns:dt",
> "urn:schemas-microsoft-com:datatypes");
>
>
>    // create a new node and set binary content
>    var l_node1 = xml_dom.createElement("file1");
>    l_node1.dataType = "bin.base64";
>    // open stream object and read source file
>    ado_stream.Type = 1;  // 1=adTypeBinary
>    ado_stream.Open();
>    ado_stream.LoadFromFile("c:\\tmp\\myfile.doc");
>    // store file content into XML node
>    l_node1.nodeTypedValue = ado_stream.Read(-1); // -1=adReadAll
>    ado_stream.Close();
>    xml_dom.documentElement.appendChild(l_node1);
>
>
>    // we can create more XML nodes for multiple file upload
>
>
>    // send XML documento to Web server
>    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
>    xmlhttp.open("POST","./file_recieve.asp",false);
>    xmlhttp.send(xml_dom);
>    // show server message in message-area
>    div_message.innerHTML = xmlhttp.ResponseText;
>
>
>
> }
>
>
> and wrote following code at server side in asp.net
> dim xml as new XMLDocument()
> xml.load(Request.InputStream)
>
> but i m gettin error as :
> root element is missing

    this error is likely appearing if the xml looks like:
<item>
    <item2>
    </item2>
</item>
<item>
    ...
</item>

it has to have 1 single root element:

<root>
    <item>
        <item2>
        </item2>
    </item>
    <item>   
        ...
    </item>
</root>

    how does your xml look like?

        FB


--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

AddThis Social Bookmark Button