# Loading XML for use in the same function?

**URL:** <https://forum.kirupa.com/t/loading-xml-for-use-in-the-same-function/262973>\
**Category:** flash\
**Created:** [June 11, 2008, 2:57pm UTC](https://forum.kirupa.com/t/loading-xml-for-use-in-the-same-function/262973 "2008-06-11T14:57:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikomax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/nikomax/32/3664_2.png) [@nikomax](https://forum.kirupa.com/u/nikomax)\
**Post date:** [June 11, 2008, 2:57pm UTC](https://forum.kirupa.com/t/loading-xml-for-use-in-the-same-function/262973/1 "2008-06-11T14:57:10Z")

</div>

Hello there,

This is sort of to do with my earlier post here:

> **[Variables in a class](https://www.kirupa.com/forum/showthread.php?p=2338801)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

What I ended up doing was having the class function [main();] call loadXML(); which would then call processXML(); when it was finished. Here is what I started using:

```auto

public function main() {
            loadXML(_targetURL);
        }
        private function loadXML(_targetURL) {
            getXMLLoad = new xmlLoad(_targetURL);
            getXMLLoad.addEventListener(Event.COMPLETE, onComplete);
        }
        private function onComplete(evt:Event) {
            xmlData = getXMLLoad.getXML();
            processXML();
        }

```

Now as I have started to restructure my code, as it wasn’t very OOP-like, I would like to call loadXML(); without having to move to a new function, thus keeping my code in one function.

Can this be done?

---

<div class="post-metadata">

**Author:** ![SmoothDime](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@SmoothDime](https://forum.kirupa.com/u/SmoothDime)\
**Post date:** [June 12, 2008, 2:56am UTC](https://forum.kirupa.com/t/loading-xml-for-use-in-the-same-function/262973/2 "2008-06-12T02:56:04Z")

</div>

what you would want to do is call loadXML() or obj.loadXML()(and make the function internal by removing the private) where obj is an instance of the class that loadXML is inside.

you should parse your xml into a data class and then access the data through your “global” data class variable.
