1 Reply Latest reply on Jan 16, 2007 9:23 AM by ntsiii

    Web Service Results Parsing Problems

    learnflex2
      The following XML is returned from a web service call and I am trying to get the attributes using a simple Flex AS. If the XML contains the Namespaces, then I am unable to retrieve the attributes and if I remove them from myXML, it works. Any pointers?

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="parse()">
      <mx:Script>
      <![CDATA[
      import mx.core.Container;
      import mx.controls.Alert;

      public function parse()
      {
      var myXML:XML =
      <authenticateUserResponse xmlns=" http://service.sample.org" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/">
      <authenticateUserReturn>
      <accountReset>false</accountReset>
      <dtCreated>2007-01-08 00:00:00.0</dtCreated>
      <dtUpdated>2007-01-08 00:00:00.0</dtUpdated>
      <email>sysadmin@testmail.com</email>
      <enabled>false</enabled>
      <firstName>SYSTEM</firstName>
      <idCreated>SYSTEM</idCreated>
      <idUpdatd>SYSTEM</idUpdatd>
      <lastName>ADMINISTRATOR</lastName>
      <lock>false</lock>
      <middleName/>
      <userID xsi:nil="true"/>
      <userRoles>
      <userRoles xsi:type="ns1:RoleVOType" xmlns:ns1=" http://beans.sample.org">
      <dtEnd>0001-01-01</dtEnd>
      <dtStart>2007-01-08</dtStart>
      <roleID>SYS_ADMIN</roleID>
      </userRoles>
      </userRoles>
      </authenticateUserReturn>
      </authenticateUserResponse>

      myXML.removeNamespace(new Namespace(" http://www.w3.org/2001/XMLSchema-instance"));
      myXML.removeNamespace(new Namespace(" http://schemas.xmlsoap.org/soap/envelope/"));
      myXML.removeNamespace(new Namespace(" http://service.sample.org"));
      myXML.removeNamespace(new Namespace(" http://beans.sample.org"));

      Alert.show(myXML.toXMLString());
      Alert.show(myXML.authenticateUserReturn.email);


      }

      ]]>
      </mx:Script>

      </mx:Application>

      If I remove the namespace attributes from the XML, Alert.show(myXML.authenticateUserReturn.email) shows the email value and otherwise it is blank.

      Appreciate your help.