Getting data from tree with a twist

I just started playing Flex and am excited by the possibilities. I read the previous question and the answers given tree obtain by a HTTPService, but can't make it work with my xml data. I have an xml file that does not have tags of regular node for the tree dataprovider. I was wondering if there was a way to get a tree to be filled with data using several names of tags and descriptions enclosed in these tags. Here's an example of my xml data to show you what I mean:

<? XML version = "1.0" encoding = "utf-8"? >

<>Catalog

< product = "Nokia" >
< name > Nokia 6010 < / name >
< description > easy to use without sacrificing style, the Nokia 6010 phone offers communication functional voice taken in charge by text messaging, e-mail, multimedia, internet mobile, games and more < / description >
< price > 99.99 < / price >
< / product >

< product = "Nokia" >
Nokia 3100 blue < name > < / name >
< description > cover light up the night with a glow-in-the-dark - when he charged with light you can easily find your phone in the dark. When you receive a call, the Nokia 3100 phone flashes in harmony with your ringtone. And when you take on a Nokia Xpress - on™ game cover *, you will get the luminescent light effects in time to the game action. < / description >
< price > 139 < / price >
< / product >
< / catalogue >

Using these data, I expect to have a folder called "Nokia", which has two files called 'Nokia 3100 blue' and 'Nokia 6010'.

So I searched the internet to see if I could get this xml format to work with a tree and this is the code I have so far:

<? XML version = "1.0" encoding = "utf-8"? >
"" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "horizontal".
creationComplete = "treeXML.send (); ">

< mx:Script >
<! [CDATA]
public void fixLabel(item:Object):String {}
var node: XML = XML (item);
If (node.localName () == 'product')
Return unescape (node.@product);
Else if (node.localName () == "name")
Return unescape (node.@name);
on the other
return ";
}
[]] >
< / mx:Script >

< mx:HTTPService id = "treeXML" url = "" data / catalog.xml "resultFormat ="e4x"/ >"


< mx:Panel width = "30%" height = "100 percent" layout = "horizontal" >
< mx:Tree width = '100% ' showRoot = "true" horizontalScrollPolicy = 'auto '.
Height = "100%" id = "mytree" dataProvider = "{treeXML.lastResult.node}" "
labelFunction labelField="@name" = "fixLabel" / >

< / mx:Panel >

< mx:Panel width = "70%" height = "100%" id = "panel1" layout = "horizontal" >
< / mx:Panel >

< / mx:Application >


However, nothing is filled in the tree. Can someone help me with this please. I think that this problem has been solved before but I don't know where to look.

Thank you for your help.

Oopps and another comment.

Loading external data in Flash (Flex) is the asynchronous process.
You should read the data loading from an external source in the (result) event handler and assign it to the variable of data tree provider here

See slightly modified code in your example below:


http://www.Adobe.com/2006/mxml"layout ="horizontal"creationComplete =" onCreationComplete () ">"


Import mx.rpc.events.ResultEvent;
Import mx.collections.XMLListCollection;

[Bindable]
private var myXMLData: XMLListCollection;

protected function onCreationComplete(): void {}
treeXML.send ();

}

protected void onDataFetched(evt: ResultEvent): void {}
var dataXML: XML = XML (evt.result);
myXMLData = new XMLListCollection (new XMLList (dataXML.children ()));
}

public void fixLabel(item:Object):String {}

var node: XML = XML (item);
If (node.localName () == 'product')
Return unescape (node.@product);
Else if (node.localName () == "name")
Return unescape (node.@name);
on the other
return ";
}
]]>



Height = "100%" id = "mytree" dataProvider = "{myXMLData}".
labelFunction labelField="@name" = "fixLabel" / >


Tags: Flex

Similar Questions

  • undefined resutl tryng to get data from flash with php

    Hello

    I'm not a coder, but I understand the way that it work and can handle already-written script. I'm going through with a problem that I do not understand why is happening. I have a php and AS3 to get results from the database. Php works fine since I test. but demand for the Flash gives me a result "undefined". I have a text box on the flash file in which is supposed to show the results of the php. So far, this code:

    AS3:

    import flash.display.*;
    import flash.events.*;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.net.URLVariables;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLRequestMethod;
    
    
        
    // Assign a variable name for our URLVariables object
    var variables:URLVariables = new URLVariables();
    //  Build the varSend variable
    var request:URLRequest = new URLRequest();
    request.url = "ckBxSample_disp.php";
    request.method = URLRequestMethod.POST;
    request.data = variables;
    // Build the varLoader variable
    var varLoader:URLLoader = new URLLoader();
    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader.addEventListener(Event.COMPLETE, completeHandler);
    try
    {
        
        varLoader.load(request);
    }
    catch (error:Error)
    {
        trace("Unable to load URL");
    }
    // Handler for PHP script completion and return
          function completeHandler(event:Event):void{
           // Load the response from the PHP file
          if (event.target.data.returnBody == "") {
            output_txt.text = "No data coming through";
          } else {
            output_txt.condenseWhite = true;
            output_txt.htmlText = "" + event.target.data.returnBody;
            
          }
        
        }
    
    // Send the data to the php file
    varLoader.load(request);
    // Ready the variables for sending
    variables.requester = "phpRows";
    
    

    in php:



    If ($_POST ['applicant'] == 'phpRows') {}

    SQL connection code

    then mysql query here

    $sql = mysql_query ("SELECT blah blah blah

    then the while loop for all records, I like to shoot

    While ($Row = blah) {}

    call lines

    $id = $row ['id'];

    sending the results of th calle by flash

    $body = "$id";

    }

    Flash results

    Print "returnBody = $body";

    Close con

    mysql_close();

    Exit();

    }

    It is most of the code and I get a result that is not defined in the text box in flash

    can anyone help? Please

    Thanks in advance

    PHP is badly formatted.  use:

    <>

    I have remove the requirement to show the result of the database

    application of Flash

    ($_POST ['applicant'] == 'phpRows');

    Connect to the databese

    include_once 'connect_to_mysql.php '.

    $tbl_name = 'table_name ';

    $body = "";

    $con = mysql_connect ($mysql_hostname, $mysql_user, $mysql_password)

    or die ("Opps Fail to connect to the host");

    @mysql_select_db ($mysql_database, $con) or die ("Opps fail to connect to database");

    $sql = mysql_query ("SELECT * FROM $tbl_name");

    $result = mysql_query ($sql);

    While ($row = {mysql_fetch_array ($sql))}

    $id = $row ['id'];

    $uname = $row ['uname'];

    $client_song = $row ["client_song"];

    $body = "$id & $uname & $client_song;

    }

    Print $body;

    mysql_close();

    Exit();

    ?>

  • Y510 unable to get data from the camera.

    Hello

    I have a Y510 with Windows Vista 32 bit, 3 GB RAM, only 5 weeks. I get this message when I try to use Veriface, "unable to get data from the camera. The camera may have been disconnected or busy. I reinstalled Vista of the State in which the laptop came, but it does not work. I also updated the bios and install other updates were available. I would appreciate any advice.

    Thank you

    Peter

    I wish it was as easy as press Fn + Esc, I looked through an another Y510 our office and managed to find a process that must be set to Auto, the process is KtmRm. This process cannot be disabled, handicapped, or on a time delay, it must be AUTOMATIC.

  • Get data from a dBASE - .dbf.

    Hello everyone - Hello work Sunday: (.) I need to get data from legacy applications that run the dbase program. You'll need to auto data. If you have an idea, please tell me. Thanks to you, NIC.

    >

    Hello everyone - Hello work Sunday: (.)

    I do not work yet--it's sad that :)

    I need to get the data from the old application
    running the program dbase. You'll need to auto data. If you have an idea, please
    say to me.

    Have a look here http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:711825134415.

    It worked for me, with a bit of difficulty – mainly because of my own stupidity... If you have
    no problem, post back.

    HTH,

    Paul...

    Thanks to you, NIC.

  • How can I get data from each associated XMLnode in movieclips separated when you click a line in the combobox

    How can I get data from each associated XMLnode in movieclips separated when you click a line in the combobox?

    A sample of XML is like this:

    <>planter

    < Lauvtre >

    < Botanisk_navn > Acer campestre < / Botanisk_navn >

    < Norsk_navn > Naverlonn < / Norsk_navn >

    Gronn < Farge > < / fan >

    H4 < Herdighet > < / Herdighet >

    < Hoyde > 10-15 m < / Hoyde >

    < / Lauvtre >

    I have a combobox where it shows the botanical name and the Norwegian name. But the rest of the info in movieclips seem separate.

    Someone has an idea how to do this? Can I use the trace function maybe? Here is my AS3 code so far:

    var loader: URLLoader = new URLLoader();

    loader.addEventListener (Event.COMPLETE, onLoaded);

    list.addEventListener (Event.CHANGE, itemChange);

    function itemChange(e:Event):void

    {

    your. Text = list.selectedItem.data;

    TB. Text = list.selectedItem.label;

    }

    var xml;

    function onLoaded(e:Event):void

    {

    XML = new XML (e.target.data);

    var it: XMLList = xml. Planter.Lauvtre;

    for (var i: uint = 0; i < il.length (); i ++)

    {

    list.addItem ({data: it.}) Farge.Text ([i]) + "\n"+ it.» Herdighet.Text ([i]) + "\n" + it. Hoyde.text ([i]),

    label: it. Botanisk_navn. Text() [i] + "\n"+ it.» Norsk_navn. Text() [i]});

    }

    }

    Loader.Load (new URLRequest ("lauvtre.xml"));

    Thank you!

    Rheus.

    I don't know what you're trying to do.  but, if you want to fill one combobox with the botanical names and when one is chosen, the other use of logins:

    var loader: URLLoader = new URLLoader();

    loader.addEventListener (Event.COMPLETE, onLoaded);

    list.addEventListener (Event.CHANGE, itemChange);

    function itemChange(e:Event):void {}

    var selectedObj:Object = a [list.selectedIndex]

    trace (selectedObj ['fan'], selectedObj ['Botanisk'], etc);

    }

    var xml;

    var a: Array = [];

    function onLoaded(e:Event):void {}

    XML = new XML (e.target.data);

    var it: XMLList = xml. Lauvtre;

    for (var i: uint = 0; i

    list.addItem({label:il[i].child('Botanisk_navn').toString()});)

    a [i] = {'Fan': it [i].child('Farge').toString (), 'Herdighet': it [i].child('Herdighet').toString (), "Hoyde": he [i].child('Hoyde').toString (), 'Botanisk':il[i].child('Botanisk_navn').toString(),'Norsk_navn':il[i].child('Norsk_navn').toString()};}

    }

    }

    Loader.Load (new URLRequest ("test.xml"));

  • How to get data from excel

    Hello world

    How can I get data from excel inside my program? I'm using labview 8.2. I have tried to find the solution for this but seems that the solutions are not suitable. Can someone help me? Thank you.

    Hi jieah,

    Inside of the attachment nijams don't you see this?

    read_excel_values. LLB

  • Get data from a member of the region partitioned customer

    Hello

    I have a partitioned area, this region is in all 3 members, is it possible to get data from this region but only from 1 member of the customer, if so how?

    What is your definition of the region on the server? The three members have given? You set redundant copies? In addition, if the optimizeForWrite() of the service method returns false, the function will run the smallest number of nodes.

    Follow these steps:

    The redundant copies of the value = 1

    Returns true for optimizeForWrite()

    Make sure that all members contain primary buckets

    Perform function like you do above

    Barry

  • How to get data from one or several times of perticuler dates

    (1) how can we get data from one or more dates perticuler.
    for example. date of 01/01/2011 and time is 00:00:00 to 23:59:59

    and

    (2) how can we get data from one or more dates perticuler.
    from date 01/01/2011 to 01/02/2011 date and time e.g. is from 00:00:00 to 23:59:59.

    can we?

    Hello

    Use a WHERE clause to include only certain lines.
    For example:

    SELECT     *
    FROM     table_x
    WHERE     dt     BETWEEN TO_DATE ( '01/01/2011 00:00:00'
                        , 'DD/MM/YYYY HH24:MI:SS'
                        )
              AND     TO_DATE ( '01/01/2011 23:59:59'
                        , 'DD/MM/YYYY HH24:MI:SS'
                        )
    ;
    

    In this example, the first date (before the keyword AND) and second (after the keyword AND) lie on the same calendar day. It's just a coincidence, they can be on different dates.
    The first date must not be later than the date of the second; If this is the case, you will get 0 found lines.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • getting data from two servers?

    Experts-

    We have two servers for the storage of the tables. 1 history 1. current server Prod

    We have same tables in the databases server.

    All the info before one month from the date of the day are stored in database tables history server
    and the rest in database tables current prod server.


    I create reports such as when the user enters a date, OBIEE must check if the date is in a month (30 days) the date today or earlier at 30 days, on this basis, it must get data from historical Server database tables / running production database server.

    How can I implement this?

    I need to create two clusters of connction (RPD records) and develop the same model twice? (One for the historical paintings and one for prod tables?)
    or can I use the technique of fragmentation? If so, can you give me an idea hwow to implement the Fragmentation of this requirement?

    Thank you for your help in advance

    You must use the fragmentation of this requirement. It is not difficult once you understand the basic principle. Nico article read here for details:

    http://gerardnico.com/wiki/dat/OBIEE/fragmentation_content

    The only non-standard bit for you will be to define the criteria of fragmentation on your sources of logical table. This is the part that says BI server to hit source.

    After return here if you get stuck.

    Paul

  • Does anyone know how to get data from a web service of Labview with ajax or JSON?

    Hello

    I try to use ajax and json to service Web restful which I build with the labview. However I get errors

    For example. I create a web service from a labview vi (z = x / y http://localhost: 8080/math/divide/5/20 will give {Z: "4,000,000"})

    I get errors for the attached html files.

    Does anyone know how to get al labview WebService with ajax or json data?

    Thank you... Eran


  • Get data from an Essbase Cube with Jean BAPTISTE

    Hello

    I'm new on the subject of japi essbase and I need help.

    I try to get some data from an essbase cube. In Excel, I used the essbase add with the function 'esscell() '.

    Is there a way to do the same thing with the japi essbase?

    If you just want to export data to a text file, then it will be probably easier to look at the following options

    DATAEXPORT - DATAEXPORT

    Script report - report writer commands

    MDX - MDX

    See you soon

    John

  • Get data from performance CPU with PowerCLI

    Can I use powerCLI to do the following:?

    -Get 2 virtual machines.

    -Get the following metric: "Application (MHz) CPU" for the last week

    -Export data to CSV

    It is indeed a compromise between the statistical data, you want to keep it online and the capacity of storage-performance on your vCenter server.

    For me there is no rule of universal thumb, you will need to find the ideal configuration for your environment and your specific needs.

    In my environment, the works of config 4, 4, 2, 2. Impact on minimum performance and I can get online reports I need.

    Don't forget that you can change the time and frequency of the aggregation jobs that run on the database, you don't have to stick with the default values.

    But be aware of the impact on the data available in each historical interval.

    And there are alternatives, as I mentioned in my answer to another of your son: Re: Getting pics of use with get-stat



  • How to get data from a URL with as3

    Hello

    I need to get data that is in the view of the source of an external Web page, how it can be done?

    URLLoader allow to get the HTML code as text, then you need extract it.

  • How to get data from a URL with as2

    Hello

    I need to get data that is in the view of the source of an external Web page, how it can be done?

    Use loadvars and our method.

  • Getting data from the nodes of event data

    Hi all

    I have a while loop with a Structure of the event and a Structure of case inside. The Structure of the event a lot of cases, and each of them is controlled by a different object (buttons, sliders, graphics, etc.). Sometimes, I have to use data from the nodes of event data to power a Business Structure that works like a State Machine in my code. To clean the block diagram, I want to 'export' data nodes using a single wire event data, but this is not possible because there is a conflict of data, since I get data of CtlRef in one case and Coords in others (for example).

    To resolve this problem, I'm feeding a beam to create a cluster and feed it to the box Structure data. However, the process is so painful, because I have to feed the Bundle function with constants of all sorts of data connected to him.

    Find attached an example. It is not the actual code but shows what I have to do.

    Thank you

    Dan07

    Why you do not pass a Variant to the structure of the case. In your case case simply make a variant of the appropriate data that you want to pass. I guess the case appropriate business structure will be to get called for the event. Given that you need to know the data type this case awaits can use the variant data VI and now you have the data you want.

Maybe you are looking for

  • iMessage on Mac Mini

    The Messages app does not work on my Mac Mini. He asks to activate account iMessage. I'm going to connect and it says: an error has occurred during authentication. It was working fine a couple of days and I not made any changes to my account. What is

  • I have burn blue ray but audio is not

    I have send to compressor and audio video is here, burn a blue ray dvd and there is no audio data

  • Z420 workstation basic model: lack of drivers/impossible to locate Z420 pre-installed model Base

    Hi all! I just picture this computer and am trying to install drivers for it.  I installed several drivers available at the Download Center of HP for this model, but have not been able to get all those that I need.  I have still several devices which

  • HP Pavilion 1201tx g6: drivers Bluetooth

    I need the drivers for my bluetooth device Hardware ID: USB\VID_0CF3 & PID_311D & REV_0001USB\VID_0CF3 & PID_311D BTH\MS_BTHBRB\7 & 2755415C & 0 & 1 Thanks in advance.

  • keep gettting response EXETender Player does not work

    When I login and start using my computer the following response keeps popping up and wont let me go any further: "EXETender {layer has stopped working." A problem caused the blocking of the program works correctly. Windows will close the program and