1 Reply Latest reply on Nov 25, 2006 9:45 AM by peterent

    XML and Flex

    M. Huisman

      Currently i'm developing a component based app in flex which should retrieve it's data from a XML file. But I can't seem to get all the info out, maybe you guys can help me out!

      I've formatted the xml like this:

      <?xml version="1.0" encoding="UTF-8"?>
      <Customer xmlns:p2="http:nl4bintern">
      <Companyname>NL for Business</Companyname>
      <Addressid type="Visit">1</Addressid>
      <Addressid type="Postal">2</Addressid>

      Now I want to get the type of the address using the @ sign, but as soon as I do, I get both id's. is there a better way to check it?

      I'm using this code:

      import views.AddressComp;
      public var editmode:Boolean;

      private var customerid:String;

      private function doInit():void {

      /* Static setting of the customerid, normally it would be done in a selection screen before the intialization of this
      perticular application.


      customerid = '1';

      if (mdlCustomer.Customerid == customerid) {
      mainPanel.title = mdlCustomer.Companyname;
      if (mdlCustomer.Address.@type == 'Visit') {
      if (mdlCustomer.Address.@type == 'Postal') {
      editmode = false;
      btnEdit.label = "Edit modus";


      In this code i'm trying to retrieve the data from the xml, and putting it to a component using a function.
        • 1. Re: XML and Flex
          peterent Level 2
          If your XML is loaded into a Flex variable which is an XMLList like this: var demo:XMLList = data.Customer; then demo.Customerid == 1; demo.Companyname == "NL for Business"; demo.Communicationid[0] == 1;

          and demo.Addressid[0].@type == "Visit" and demo.Addressid[1].@type == "Postal"

          should take care of the problem.