# Private/public problem

**URL:** <https://forum.kirupa.com/t/private-public-problem/231397>\
**Category:** Uncategorized\
**Created:** [July 4, 2007, 12:28pm UTC](https://forum.kirupa.com/t/private-public-problem/231397 "2007-07-04T12:28:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruhe](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Ruhe](https://forum.kirupa.com/u/Ruhe)\
**Post date:** [July 4, 2007, 12:28pm UTC](https://forum.kirupa.com/t/private-public-problem/231397/1 "2007-07-04T12:28:38Z")

</div>

Hi.  
Everything I need is find some nodeValue in xml file like this:

```auto

<school name="13">
  <place name="facade">1.jpg</place>
  <place name="entrance">2.jpg</place>
<school>

```

I wrote an abstract xml class which loads file:

```auto

class ruhe.util.AbstractXML extends XML 
{
    
    private var link:String;
    private var event:String = "onXMLLoad";
    private var errorEvent:String = "onXMLLoadError";
    
    var dispatchEvent:Function;
    var addEventListener:Function;

    public function AbstractXML(xml_url : String)
    {
        super();
        EventDispatcher.initialize(this);
        ignoreWhite = true;
        link = xml_url;
        this.load(link);
    }
    
    private function onLoad(success:Boolean):Void
    {
        if(success)
        {
            this.dispatchEvent({type: event});
        }
        else
        {
            this.dispatchEvent({type: errorEvent});    
        }
    }

}

```

and xml handler class:

```auto

class ruhe.school.XmlHandler {

    private var info : AbstractXML;
    private var hash : Object;

    public function XmlHandler() 
    {
        info = new AbstractXML("tree.xml");

        info.addEventListener("onXMLLoad", Proxy.create(this, processXML));
        info.addEventListener("onXMLLoadError", Proxy.create(this, raiseError));
    }

    private function raiseError() : Void
    {
        throw new Error("no xml found");
    }

    private function processXML() : Void{}

    public function find(lookFor : String) : String
    {
        for (var n : Number = 0; n < info.firstChild.childNodes.length; n++)
        {
            if(info.firstChild.childNodes[n].attributes.name == lookFor)
            {
                return info.firstChild.childNodes[n].firstChild.nodeValue;
            }
        }
    }
}

```

\*\*find \*\*method doesn’t work. it returns **undefined**. But when I change it to private and call from the \*\*processXML \*\*method everything works well.

```auto

private function processXML() : Void
{
    trace (this.find("entrance")); *==> 2.jpg*
}

private function find(lookFor : String) : String
{
    for (var n : Number = 0; n < info.firstChild.childNodes.length; n++)
    {
        if(info.firstChild.childNodes[n].attributes.name == lookFor)
        {
            return info.firstChild.childNodes[n].firstChild.nodeValue;
        }
     }
 }

```

I thinck there is a stupid mistake somewhere in my code. I need public function **find** , not private.
