2 Replies Latest reply on Sep 11, 2009 5:11 AM by tooMuchTrouble

    how to refer to dynamic XML elements?

    tooMuchTrouble Level 3
      (covering all my bases also posted to flexcoders list)

      i have an XML response from a server that has a gazillion elements in it where i
      need to use a few of these. the required element names are defined elsewhere &
      read in at run time. the XML response is something along the lines of:

      <gml:featureMembers>
           <topp:runoffdatapoints gml:id="runoffdatapoints.1">
                <topp:UPSTREAMAREASQKM>20.8503</topp:UPSTREAMAREASQKM>
                <topp:ID>13469</topp:ID>
                <topp:QMCUBED>9.8567</topp:QMCUBED>
           </topp:runoffdatapoints>
      <<gml:featureMembers>

      the namespaces are all defined ok & work fine if used statically.

      for each (x in result.gml::featureMembers.topp::runoffdatapoints) {
           id=x.topp::ID; // works just fine
      }

      but i'm having a brain freeze trying to understand how to refer to the required
      elements dynamically. like

      var runoffIDField:String="topp::ID";

      for each (x in result.gml::featureMembers.topp::runoffdatapoints) {
           id=x[runoffIDField]; // nope
           id=x.child(runoffIDField); // ditto     
      }

      i guess the namespace is playing havoc w/this.

      anyone have any ideas or references?

      thanks.







        • 1. Re: how to refer to dynamic XML elements?
          tooMuchTrouble Level 3

          PaulH wrote:

           

          i have an XML response from a server that has a gazillion elements in it where i 
          need to use a few of these. the required element names are defined elsewhere &
          read in at run time. the XML response is something along the lines of:

          <gml:featureMembers>
               <topp:runoffdatapoints gml:id="runoffdatapoints.1">
                    <topp:UPSTREAMAREASQ KM>20.8503</topp:UPSTREAMAREASQKM>
                    <topp:ID>13469</topp :ID>
                    <topp:QMCUBED>9.8567 </topp:QMCUBED>
               </topp:runoffdatapoints>
          <<gml:featureMembers>

          the namespaces are all defined ok & work fine if used statically.

          for each (x in result.gml::featureMembers.topp::runoffdatapoints) {
               id=x.topp::ID; // works just fine
          }

          but i'm having a brain freeze trying to understand how to refer to the required
          elements dynamically. like

          var runoffIDField:String="topp::ID";

          for each (x in result.gml::featureMembers.topp::runoffdatapoints) {
               id=x[runoffIDField]; // nope
               id=x.child(runoffIDField); // ditto    
          }

          i guess the namespace is playing havoc w/this.

          anyone have any ideas or references?

          thanks.








           

          still getting nowhere with this. *any* suggestions? even suggestions on what terms to search on?

           

          thanks.

          • 2. Re: how to refer to dynamic XML elements?
            tooMuchTrouble Level 3

            well it never occurred to me that i would have *search* for these things:

             

            var runoffIDField:String="ID"; // lose the namespace, use local name instead

             

            for each (x in result.gml::featureMembers.topp::runoffdatapoints) {
                id=x.children().(name().localName==runoffIDField);
            }

             

            geez, i really have a mental block w/xml.