Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i am working with xml and html and i knew to this concepts, When itried to load my xml file, i get an Error. I dont know why did i get this error. I will send my code througth this query. If anyone please help me in solve this probelm.

XML
<html>
<head>
<script>
    function loadXMLDoc(file)
    {
        try
        {
            xmlDoc=new XMLHttpRequest();
        }
        catch(e)
        {
            try
            {


xmlDoc=document.implementation.CreateDocument("","",null);
            alert("Browser mozile");
            }
            catch(E)
            {
                alert(E.message);
            }
        }

        try
        {
            xmlDoc.open("GET",file,false);
            xmlDoc.send();
            return(xmlDoc);
        }
        catch(e)
        {
            alert("Not loaded the xml file because of raises

exception");
            alert(e.message);
        }
        alert("not loaded");
        return(null);
    }

    function getNeela()
    {
        var xmlFile=loadXMLDoc("C:\mani\programming\xml

programs\test.xml");

        var neelacount=xmlFile.getElementsByTagname

("neela").length;
    for(i=0; i<neelacount;i++)
    {
        document.getEelmentById

("target").innerHTML+=xmlFile.getElementsByTagName("neela")[i].childNodes

[0].nodeValue;
    }
    }
</script>
</head>
<body onload="getNeela()">
<b>Text from the xml file:</b>
</body>
</html>


When i executing this html file in chrome i get the error
"Network_Err: XMLHttpRequest Exception 101"
In case of IE7 i got the error "access denied."
Can any one tell the solution fro this problem.

Regards,
Manikanta.
Posted

1 solution

Hi,

Below example is not in a Client Code rather in .ASPX code nor in html.
In our part we do loading xml file in code behind...


Try this sample if could help:

string file = AppDomain.CurrentDomain.BaseDirectory + @"XMLSource\test.xml"
DataSet myDs = new DataSet();
myDs = loadXMLDoc(file);
// Do something here?....
//....

public virtual DataSet loadXMLDoc(file)
{
    DataSet ds = null;
    try
    {
       ds = new DataSet();
       ds.ReadXml(file);
    }
    catch
    { }
    return ds;
}

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Hope this could help...

Regards,

Algem
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900