8 Replies Latest reply on May 12, 2009 11:29 AM by Mrjavali

    XML attribute Undefined?!?

    Mrjavali Level 1

      Hey Flashers!!

      I need some help on the following:

      I am on AS2.0, CS4:

       

      i am trying to extract the following data from the XML attribute:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mytext>
      < text ida="Hello world!" idb= "bye World!">
      </mytext>
      

       

      Here's my AS2.0 code, i tried to load the xml attributes into the two separate dinamic text fields:

       

      //load css
      var styles:TextField.StyleSheet = new TextField.StyleSheet();
      styles.setStyle("a:link",{textDecoration:'underline'});
      styles.setStyle("a:hover",{color:'#FF0000'});

       

      _parent.home_text.styleSheet = styles;
      /******************************/
      //load in XML

       

      var meuXML:XML = new XML();
      meuXML.load("xml/content.php");
      meuXML.ignoreWhite = true;

       

      meuXML.onLoad = function() {
      _parent.home_text.htmlText = this.childNode[0].childNodes[0].attributes.ida;

      _parent.contacts_text.htmlText = this.childNodes[0],childNode[0].attributes.idb;


      };

       

       

      I keep getting an Undefined error...

      Anyone??

      Thanks!!

      Cheers!

        • 1. Re: XML attribute Undefined?!?
          kglad Adobe Community Professional & MVP

          there are several errors, both in your xml file and your actionscript.

           

          your text node shouldn't have a space before text and it should be closed.

           

          and childNode should be childNodes in both lines of actionscript.

          1 person found this helpful
          • 2. Re: XML attribute Undefined?!?
            Mrjavali Level 1

            Is this correct? i can't get it work anyway...

             

            <?xml version="1.0" encoding="utf-8"?>
            <mytext>
            <text ida="Hello world!" idb= "bye World!"></text>
            </mytext>

             

            AS2.0 code:

             

            //load css
            var styles:TextField.StyleSheet = new TextField.StyleSheet();
            styles.setStyle("a:link",{textDecoration:'underline'});
            styles.setStyle("a:hover",{color:'#FF0000'});

             

            _parent.home_text.styleSheet = styles;
            /******************************/
            //load in XML

             

            var meuXML:XML = new XML();
            meuXML.load("xml/content.php");
            meuXML.ignoreWhite = true;

             

            meuXML.onLoad = function() {
            _parent.home_text.htmlText = this.childNodes[0].childNodes[0].attributes.ida;

            _parent.contacts_text.htmlText = this.childNodes[0],childNodes[0].attributes.idb;


            };

             

             

             

             

             


            • 3. Re: XML attribute Undefined?!?
              kglad Adobe Community Professional & MVP

              that looks good.

               

              so, if that fails, check your textfields.  you probably have a path reference problem.

               

              what's

               

              trace(_parent.home_text) show in your onLoad method?

              • 4. Re: XML attribute Undefined?!?
                Mrjavali Level 1

                Well you were right Kglad, i did have a reference problem!

                So i test it and it worked!!! Even the trace show me the xml data...

                 

                But now i have a new issue, when it comes to test it online, it keep giving me the "undefined" error...

                anyone??

                 

                Thanks Kglad for you help so far...

                Cheers!

                • 5. Re: XML attribute Undefined?!?
                  kglad Adobe Community Professional & MVP

                  use trace(this) other use a textfield to display "this" in your xml onLoad to see what's being loaded.

                   

                  if your xml is not being loaded look for a case mismatch like content.XML or Content.xml

                  • 6. Re: XML attribute Undefined?!?
                    Mrjavali Level 1

                    Anyone can help me in that matter?

                    so i have on the AS code:

                     

                    meuXML.load("xml/content.php");

                     

                    i test it locally, and it works, but when i upload it to the server...Not working anymore...

                     

                    so i change the extension to:

                     

                    meuXML.load("xml/content.xml");

                     

                    And now it's working!!!

                     

                    BUT!! (There's always a but), i need the extension to be "content.php" for the CMS.

                    Why the server can´t handle the file conten.php as a xml...

                    Anyone???

                     

                    Thanks!

                    • 7. Re: XML attribute Undefined?!?
                      kglad Adobe Community Professional & MVP

                      is php installled on your server?

                      • 8. Re: XML attribute Undefined?!?
                        Mrjavali Level 1

                        yes i do, i have a PHP contact form and it's working very well.

                        Seriously, i am getting mad about this...

                         

                        Thanks for your help Kglad!!