7 Replies Latest reply on Sep 2, 2009 8:28 AM by sergei_developer

    From string to XML

    Revlex

      Hi,

       

      How can i convert a string to XML so i can use it's tags?

        • 1. Re: From string to XML
          Richard_Abbott Level 3

          Revlex

          var s: string;

          var x: XML;

          s = "<root><a>a_text</a><b>b_text</b></root>";

          x = XML(s);

           

          Richard

          1 person found this helpful
          • 2. Re: From string to XML
            Revlex Level 1

            actually i fixed it kind of but now i have a new problem how can i make sure that i can put text in an textarea while using xml this is my xml build up:

             

            <info>
              <titel>eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee</titel>
              <tekst_stuk>weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee</tekst_stuk>
              <foto>P1000098.JPG</foto>
              <foto_2>P1000098.JPG</foto_2>
              <foto_3>P1000098.JPG</foto_3>
              <foto_4>P1000098.JPG</foto_4>
            </info>

            • 3. Re: From string to XML
              sergei_developer Level 1

              var x:XML = <info>
                <titel>eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee</titel>
                <tekst_stuk>weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee</tekst_stuk>
                <foto>P1000098.JPG</foto>
                <foto_2>P1000098.JPG</foto_2>
                <foto_3>P1000098.JPG</foto_3>
                <foto_4>P1000098.JPG</foto_4>
              </info>;

              var s:String = x.toString();

              something like this

              1 person found this helpful
              • 4. Re: From string to XML
                Revlex Level 1

                sorry my bad i meant updating a textArea with the information between the start tag and the end tag like <info><titel>blaaaaaaat</titel></info>

                the information i want to extract and put in to the textbox is blaaaaat but the question is: How do i do it?

                 

                im searching and trying it for like an hour now

                 

                EDIT: I have found out how it works tnx for the help guys!

                • 5. Re: From string to XML
                  sergei_developer Level 1

                  you have to use :

                  var x:XML =<info><titel>blaaaaaaat</titel></info>;

                  var s:String = x.info.@title;

                  • 6. Re: From string to XML
                    Barna Biro Level 3

                    sergei_developer wrote:

                     

                    you have to use :

                    var x:XML =<info><titel>blaaaaaaat</titel></info>;

                    var s:String = x.info.@title;

                     

                    That code is incorrect and it won't work. "titel" is not an attribute but a node so you should access it that way and also, the root node ( called "info" ) is considered implicit, which means that you would access the "titel" node this way: var s:String = x.titel;

                     

                    Good luck,

                    Barni

                    • 7. Re: From string to XML
                      sergei_developer Level 1

                      Yes, I was wrong . I forgot that "@" we use for attribute . You right , Barna Biro!