School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,490 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,820 people online right now. Registration is fast and FREE... Join Now!




XML File location help

 

XML File location help

mineeric123

4 Jul, 2009 - 12:59 PM
Post #1

New D.I.C Head
*

Joined: 12 Nov, 2008
Posts: 36



Thanked: 1 times
My Contributions
Hello All,


I am having trouble getting to the correct file. I have an XML file named google.XML that is located in the App_Data folder. I have an Asp.net page named incidents located in the same web project but in folder named incidents. If I place the google.XML file in the folder named incidents the code below works just fine, but if I put it in the App_Data folder, I get the evil 404 error. I believe my problem is I have not correctly point to the correct folder, but I have tried every combination I can think of. If anyone has any ideas, I would be forever grateful.


Below is the code.

Also, I know this is all javascript, but I thought the question was more relevant to Asp.net and not javascript, if I am wrong please move this to the correct forum.

CODE

var xmlhttp = false;


        getHTTPRequestObject();
        function getHTTPRequestObject() {
            try {
                //try legacy object first
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    //try IE implementation now
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (E) {
                    xmlhttp = false;
                }
            }
            if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
                xmlhttp = new XMLHttpRequest();
            }
        }
        function getXMLData()
        {
            xmlhttp.open("GET", "App_Data\google.xml", true);
            xmlhttp.onreadystatechange = callback;
            xmlhttp.send(null);
        }    
        
        

        function callback() {
            if (xmlhttp.readyState == 4) {
                if (xmlhttp.status == 200) {
                    var xmlresponse = xmlhttp.responseXML.documentElement;
                    var textresponse = xmlhttp.responseText;
                    var finddiv = document.getElementById("divResponse");
                    finddiv.innerText = textresponse;
                   // alert(trimString(xmlresponse.getElementsByTagName
                   //("marker")[0].firstChild.data));
                }
            }

        }


User is offlineProfile CardPM
+Quote Post


PsychoCoder

RE: XML File Location Help

4 Jul, 2009 - 01:14 PM
Post #2

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Try this

CODE

function getXMLData()
{
            xmlhttp.open("GET", "../App_Data/google.xml", true);
            xmlhttp.onreadystatechange = callback;
            xmlhttp.send(null);
}    


Also, since this is JavaScript I'm going to move it to the JavaScript forum smile.gif
User is offlineProfile CardPM
+Quote Post

mineeric123

RE: XML File Location Help

4 Jul, 2009 - 02:20 PM
Post #3

New D.I.C Head
*

Joined: 12 Nov, 2008
Posts: 36



Thanked: 1 times
My Contributions
Hello Psycho coder and everyone else,

That did not work, but thanks for moving the post

Regards,

Eric
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: XML File Location Help

4 Jul, 2009 - 05:55 PM
Post #4

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
I think your problem is you cannot reference the App_Data folder directly like that (At least I don't think you can). I keep my XML files in a folder named XmlFiles. If you do that then this should work

CODE

function getXMLData()
{
            xmlhttp.open("GET", "../XmlFiles/google.xml", true);
            xmlhttp.onreadystatechange = callback;
            xmlhttp.send(null);
}    

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:25AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month