4 Replies Latest reply on Dec 14, 2006 12:08 PM by wushupork

    XML object help

    wushupork
      I'm having major problems with what seems to be a straight forward thing. I have an XML object that looks like this:

      <SearchResponse xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns=" http://tempuri.org/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema">
      <SearchResult>
      <node>
      <cluster FullName=", copyright, rights reserved" Name="copyrightrights reserved">
      <doc teaser="Teaser" url="APPLICAT.PPT" rank="1887" size="361472" thumbs="true" title="Doc Title"/>
      <doc teaser="Teaser" url="APPLICAT.PPT" rank="1887" size="361472" thumbs="true" title="Doc Title"/>
      <doc teaser="Teaser" url="APPLICAT.PPT" rank="1887" size="361472" thumbs="true" title="Doc Title"/>
      </cluster>
      <cluster FullName="app server, application server, bea weblogic" Name="app serverapplication serverbea weblogic">
      <doc teaser="Teaser" url="APPLICAT.PPT" rank="1887" size="361472" thumbs="true" title="Doc Title"/>
      <doc teaser="Teaser" url="APPLICAT.PPT" rank="1887" size="361472" thumbs="true" title="Doc Title"/>
      <doc teaser="Teaser" url="APPLICAT.PPT" rank="1887" size="361472" thumbs="true" title="Doc Title"/>
      </cluster>
      </node>
      </SearchResult>
      <SearchResponse>

      I'm basically just trying to loop through it using something like this:

      for(var i:Number=0; i<clusters_xml.node[0].cluster.length(); i++)
      {
      var clusterNode_xml:XML = clusters_xml.node[0].cluster ;

      for(var j:Number=0; j<clusterNode_xml.doc.length(); j++)
      {
      var docNode:XML = clusterNode_xml.doc[j];
      all_xml.appendChild(docNode);
      }
      }

      The thing is, it works with an XML file with the SAME data using HTTPService, but when it's a WebService - it just doesnt work. I set the resultFormat to e4x on both
        • 1. XML object help
          wushupork Level 1
          I forgot to mention:

          var clusters_xml:XML = new XML(event.result);

          Alert.show(clusters_xml.node.cluster.length());

          keeps returning 0
          • 2. Re: XML object help
            ntsiii Level 3
            Sneak up on it. Make sure "clusters_xml" then "node[0]" is evaluating correctly. Use toXMLString() to examine each node as you traverse the tree.

            Namespace issues might be causing a problem.

            Tracy
            • 3. Re: XML object help
              wushupork Level 1
              how do i handle the namespaces?

              something like this ?
              clusters_xml.removeNamespace(clusters_xml.namespace("xsi"));
              clusters_xml.removeNamespace(clusters_xml.namespace("xsd"));
              clusters_xml.removeNamespace(clusters_xml.namespace("soap"));

              there's still the one called http://tempuri.org/
              which I cant get rid of even by using something like
              clusters_xml.removeNamespace(clusters_xml.namespaceDeclarations()[0]);
              • 4. Re: XML object help
                wushupork Level 1
                i got it -

                code looks sort of like this;
                for(var i:Number=0; i<clusters_xml.children().node[0].children().length(); i++)
                {
                var clusterNode_xml:XML = clusters_xml.children().node[0].children() ;

                for(var j:Number=0; j<clusterNode_xml.children().length(); j++)
                {
                var docNode:XML = clusterNode_xml.children()[j];
                all_xml.appendChild(docNode);
                }
                }

                not exactly what i had in mind