Skip to main content
Participating Frequently
January 14, 2011
Answered

server-side XML class it's HORRIBLE help please

  • January 14, 2011
  • 1 reply
  • 1000 views

I've worked with XML in AS2, was bad, but i did not complain, in AS3 was perfect, but in server-side FMS is COMPLETLY HORRIBLE i just can't work with it, I'm feeling sick, realy, I feel something in the pit of my stomach, this is not ment to be used. for the first time I can only work with this if someone helps me in a forum:

I have a XML like this:

<root>

     <rooms>

          <room>

               <name>hello</name>

               <id>123</id>

          </room>

          <room>

               <name>normal_room</name>

               <id>321</id>

          </room>

          <room>

               <name>special_room</name>

               <id>666</id>

          </room>

     </rooms>

</root>

i loaded it successfully into a XML object, but I simply can't access the "id" tag of every "room" in a for loop, I tried to do this in many ways, it's not like in AS2. I need some help with this, tanks.

    This topic has been closed for replies.
    Correct answer manish_kumar2

    Hi,

    Try this server side code:

    application.onConnect=function(clientObj){
        trace("Connected");
        application.acceptConnection(clientObj);
        application.onNCA(clientObj);
    }

    application.onNCA=function(clientObj){
        url="http://example.com/example/example.xml";
        trace(url);
        xmlObj=new XML();
        xmlObj.onLoad=function(success){
            trace(success);
            for(prop1 in xmlObj.firstChild.childNodes){
                for(prop2 in xmlObj.firstChild.childNodes[prop1].childNodes){
                    for (prop3 in xmlObj.firstChild.childNodes[prop1].childNodes[prop2].childNodes){
                       
                        if(xmlObj.firstChild.childNodes[prop1].childNodes[prop2].childNodes[prop3].nodeName == "id"){
                            trace(xmlObj.firstChild.childNodes[prop1].childNodes[prop2].childNodes[prop3].firstChild.nodeValue);
                        }
                    }
                }
            }
        }
       
        xmlObj.load(url);
    }

    1 reply

    manish_kumar2Correct answer
    Participating Frequently
    January 14, 2011

    Hi,

    Try this server side code:

    application.onConnect=function(clientObj){
        trace("Connected");
        application.acceptConnection(clientObj);
        application.onNCA(clientObj);
    }

    application.onNCA=function(clientObj){
        url="http://example.com/example/example.xml";
        trace(url);
        xmlObj=new XML();
        xmlObj.onLoad=function(success){
            trace(success);
            for(prop1 in xmlObj.firstChild.childNodes){
                for(prop2 in xmlObj.firstChild.childNodes[prop1].childNodes){
                    for (prop3 in xmlObj.firstChild.childNodes[prop1].childNodes[prop2].childNodes){
                       
                        if(xmlObj.firstChild.childNodes[prop1].childNodes[prop2].childNodes[prop3].nodeName == "id"){
                            trace(xmlObj.firstChild.childNodes[prop1].childNodes[prop2].childNodes[prop3].firstChild.nodeValue);
                        }
                    }
                }
            }
        }
       
        xmlObj.load(url);
    }

    fermmmAuthor
    Participating Frequently
    January 14, 2011

    tanks man