Question: I am trying to load an xml file that is on my local system. But I always get Network\_err. I do the following.

```
function LoadXmlDoc(dName)
{
    var xhttp;
    if(window.XMLHttpRequest)
    {
        xhttp = new XMLHttpRequest();
    }
    else
    {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    try
    {       
        xhttp.open("GET", "file.xml", false);
        xhttp.send();
    }
    catch(e)
    {       
        window.alert("Unable to load the requested file.");
        return;
    }
    return xhttp.responseXML;
}

```

How can I load an xml file that is on my system. all files are in same folder on my pc. Thanks

Answer: 
Firstly they way this im implemented is not awesome. There is a lot that could be done better but Im not going to try to change you implementation here... :)

To do what you want to do, that is access a global variable without knowing its actual name, can be done like this.

```
window[drugname + "qty"] = drugqty;

```

This works because

1. "Global" variable in a browser are actually on the window object
2. objects in JavaScript are associative arrays. Which in simple terms means you can access its properties via it name as you would in a Key Value pair
You can use the [`eval()`](http://www.w3schools.com/jsref/jsref_eval.asp) function for this:

```
eval(drugname+"qty"=drugqty);

```

*Note*: It would be much better to learn about Object Oriented programming. So you can make a `Drug` [class](https://stackoverflow.com/questions/387707/whats-the-best-way-to-define-a-class-in-javascript) and class instances (objects) of this class to store the particular drug information. It is easy pass around these classes and keep track of the information!