XML to DataGrid

Hi,
I was wondering if you could help me, I know Im close I just
need a little push
I am trying to load an XML file to a datagrid and I have this
hic up..
This is my XML file
<string>
<English>
<greeting>Welcome</greeting>
<thanks>Thank You</thanks>
</English>
<Français>
<greeting>Bienvenue</greeting>
<thanks>Merci</thanks>
</Français>
</string>
This is the Code..
Code:
var shopXML:XML = new XML();
var masterArray:Array = new Array();
shopXML.ignoreWhite = true;
shopXML.onLoad = function(success) {
if (success){
trace("YES");
var currentShopNode:XMLNode = this.firstChild.firstChild;
var i:Number = 0;
for (var childNode = currentShopNode; childNode != null;
childNode = childNode.nextSibling, i++) {
masterArray
= new Array();
masterArray[0] = childNode.nodeName;
j++;
for (var stringNode:XMLNode = childNode.firstChild;
stringNode != null; stringNode = stringNode.nextSibling, j++) {
masterArray
[j] = stringNode.firstChild.nodeValue;
shops_datagrid.dataProvider = masterArray;
} else {
trace("NOPE");
// load the XML file
shopXML.load("sample.xml");
This is the output:
Code:
NaN 0
Thank you Welcome
Merci Bienvenue
The problem is with the column headers
What It should do is have NaN = thanks and 0 = greeting
I would really Appreciate it if you could help me..Thanks for
anykind of help!
null

Hi,
I was wondering if you could help me, I know Im close I just
need a little push
I am trying to load an XML file to a datagrid and I have this
hic up..
This is my XML file
<string>
<English>
<greeting>Welcome</greeting>
<thanks>Thank You</thanks>
</English>
<Français>
<greeting>Bienvenue</greeting>
<thanks>Merci</thanks>
</Français>
</string>
This is the Code..
Code:
var shopXML:XML = new XML();
var masterArray:Array = new Array();
shopXML.ignoreWhite = true;
shopXML.onLoad = function(success) {
if (success){
trace("YES");
var currentShopNode:XMLNode = this.firstChild.firstChild;
var i:Number = 0;
for (var childNode = currentShopNode; childNode != null;
childNode = childNode.nextSibling, i++) {
masterArray
= new Array();
masterArray[0] = childNode.nodeName;
j++;
for (var stringNode:XMLNode = childNode.firstChild;
stringNode != null; stringNode = stringNode.nextSibling, j++) {
masterArray
[j] = stringNode.firstChild.nodeValue;
shops_datagrid.dataProvider = masterArray;
} else {
trace("NOPE");
// load the XML file
shopXML.load("sample.xml");
This is the output:
Code:
NaN 0
Thank you Welcome
Merci Bienvenue
The problem is with the column headers
What It should do is have NaN = thanks and 0 = greeting
I would really Appreciate it if you could help me..Thanks for
anykind of help!
null

Similar Messages

  • Problems with XML and Datagrid!

    Hi!
    Trying to follow a similar idea to the app shown on the flex
    homepage - i have the following code:
    [code]
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="srv.send()">
    <mx:HTTPService id="srv"
    url="lab-cs3.cs.st-andrews.ac.uk/~aa322/mytube.xml"/>
    <mx:DataGrid
    dataProvider="{srv.lastResult.videos.video}"/>
    </mx:Application>
    [/code]
    However, when I run the application - it gives the following
    error:
    [RPC Fault faultString="Error #2148: SWF file
    file:///C:/Documents and Settings/Andy/My Documents/Flex Builder
    3/HelloWorld/bin-debug/HelloWorld.swf cannot access local resource
    lab-cs3.cs.st-andrews.ac.uk/~aa322/mytube.xml. Only
    local-with-filesystem and trusted local SWF files may access local
    resources." faultCode="InvokeFailed" faultDetail="null"]
    at mx.rpc::AbstractInvoker/
    http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\ src\mx\rpc\AbstractInvoker.as:263
    at mx.rpc.http.mxml::HTTPService/
    http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\3.0.x\frameworks\projects\rpc\ src\mx\rpc\http\mxml\HTTPService.as:234
    at
    mx.rpc.http::HTTPService/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\http\HTTP Service.as:758]
    at
    mx.rpc.http.mxml::HTTPService/send()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\http \mxml\HTTPService.as:217]
    at
    HelloWorld/___HelloWorld_Application1_creationComplete()[C:\Documents
    and Settings\Andy\My Documents\Flex Builder
    3\HelloWorld\src\HelloWorld.mxml:2]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at
    mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\co re\UIComponent.as:9051]
    at mx.core::UIComponent/set
    initialized()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1167]
    at
    mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:698]
    at Function/
    http://adobe.com/AS3/2006/builtin::apply()
    at
    mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\sr c\mx\core\UIComponent.as:8460]
    at
    mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src \mx\core\UIComponent.as:8403]
    and fails to connect to the xml i think.
    Any ideas on what I am doing wrong?!
    Thanks
    Andy

    You need to specify the full URL. I would also suggest using
    a result handler to assign the xml to your DataGrid dataProvider.
    Below is a sample. I set the resultFormat to e4x, which is XML.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="srv.send()">
    <mx:HTTPService id="srv"
    url="
    http://lab-cs3.cs.st-andrews.ac.uk/~aa322/mytube.xml"
    result="videoListLoaded(event)"
    resultFormat="e4x"/>
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    [Bindable] private var videoList:XML;
    private function videoListLoaded(evt:ResultEvent):void {
    videoList = evt.result as XML;
    ]]>
    </mx:Script>
    <mx:DataGrid x="10" y="10" id="videos_dg"
    dataProvider="{videoList.video}">
    <mx:columns>
    <mx:DataGridColumn width="200" headerText="label"
    dataField="label"/>
    <mx:DataGridColumn width="300" headerText="URL"
    dataField="url"/>
    <mx:DataGridColumn width="50" headerText="views"
    dataField="views"/>
    <mx:DataGridColumn width="150" headerText="Category"
    dataField="category"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Application>
    Vygo

  • Load xml to Datagrid, add row or edit and save it to the xml file??

    Good afternoon,
    I know how to load the xml, add a row or edit the data in a datagrid . Only thing I dont't  know
    how to save the changes to the xml file. I'm ussing Flash Professional CC and it wil be an Adobe Air
    desktop application.

    Hi, and thank for the reply. Problem is not saving the xml, but getting the edited or new rows in the datagrid  to be saved in the xml.....

  • Xml in datagrid instead of a proper result

    Hi
    I'm new to FDS and I have a problem to show my data in my
    data grid. As you can see below I have a datagrid and a button.When
    I click on the button I search for every item which contains 'BA'
    but instead of giving me all the items of my search results, the
    data grid gives me my search result in a xml-format:
    <articles><article><number>262</number><description>BALPEN
    BIC M10 BLAUW</description></article>
    Has anybody have had a similar problem and found a solution?
    Thanks!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    backgroundColor="#FFFFFF" viewSourceURL="srcview/index.html">
    <mx:WebService id="srv" wsdl="
    http://localhost:8080/axis/ArticleService.jws?wsdl"
    showBusyCursor="true"/>
    <mx:DataGrid dataProvider="{srv.getArticles.lastResult}"
    width="100%" height="100%">
    <mx:columns>
    <mx:DataGridColumn dataField="article.number"
    headerText="Article Number"/>
    <mx:DataGridColumn dataField="article.description"
    headerText="Description"/>
    </mx:columns>
    </mx:DataGrid>
    <mx:Button label="Get Data"
    click="srv.getArticles('BA')"/>
    </mx:Application>

    Note that this issue would be technically unrelated to FDS
    (now known as
    LCDS - the latest version being LCDS 2.5.1), but rather it
    concerns WebServices
    and the decoding SOAP into ActionScript objects. That is, FDS
    is not required
    to use WebServices in Flex (unless you need the proxy
    service) and FDS does
    not decode the SOAP responses - that is something that the
    rpc.swc client
    library does from the Flex SDK.
    Depending on the version of Flex that you're using, it may be
    a bug in the
    <mx:WebService> implementation in the Flex SDK?
    A new <mx:WebService> implementation was provided in
    the Flex SDK which was
    first made available in LCDS 2.5 which co-incided with Flex
    SDK 2.0.1 Hotfix
    2, and will be more widely exposed in Flex 3 (which is
    currently in Beta).
    The latest nightly builds for the Flex SDK 2.0.1 can be found
    here:
    http://labs.adobe.com/technologies/flex/sdk/flex2sdk.html
    The latest nightly builds for the Flex SDK 3 Beta can be
    found here:
    http://labs.adobe.com/technologies/flex/sdk/flex3sdk.html
    If you find a problem with WebServices, please log a bug
    against the Flex
    SDK at the public bug repository:
    http://bugs.adobe.com/flex/
    You can log the bug under the "RPC: WebService" component.
    When logging a WebService bug, it's best to provide the WSDL,
    any XML Schema
    imports, a snippet of MXML or AS3 code that you used to call
    an operation
    and process the result (as you did in your post), and ideally
    a capture of
    the SOAP response as XML.
    Regards,
    Pete
    > Hi
    >
    > I'm new to FDS and I have a problem to show my data in
    my data grid.
    > As you can see below I have a datagrid and a button.When
    I click on
    > the button I search for every item which contains 'BA'
    but instead of
    > giving me all the items of my search results, the data
    grid gives me
    > my search result in a xml-format:
    >
    <articles><article><number>262</number><description>BALPEN
    BIC M10
    > BLAUW</description></article>
    >
    > Has anybody have had a similar problem and found a
    solution?
    >
    > Thanks!
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > backgroundColor="#FFFFFF"
    viewSourceURL="srcview/index.html">
    > <mx:WebService id="srv"
    > wsdl="
    http://localhost:8080/axis/ArticleService.jws?wsdl"
    > showBusyCursor="true"/>
    > <mx:DataGrid
    dataProvider="{srv.getArticles.lastResult}"
    > width="100%"
    > height="100%">
    > <mx:columns>
    > <mx:DataGridColumn dataField="article.number"
    headerText="Article
    > Number"/>
    > <mx:DataGridColumn dataField="article.description"
    > headerText="Description"/>
    > </mx:columns>
    > </mx:DataGrid>
    > <mx:Button label="Get Data"
    click="srv.getArticles('BA')"/>
    > </mx:Application>

  • Display xml in Datagrid

    Hi All,
    After fiddling this for almost a week, I finally come in seek
    of assistance and advice. let me explain my requirement as clearly
    as I possibly can. before you even proceed further, please make
    sure you a aware of the following:
    importing xml into flash
    usnig the XPathApi
    using datasets and Datagrids
    Summary
    I have a complex XML file (refer link below) that is
    generated from a database. my client wants these generated data to
    be displayed in a presentable format so that any visitor using this
    application can instantly get the data by querying into the XML
    File.
    I tried doing this with XML and XSLT i was able to display
    the data in a presentable format. but I faced an issue. I was
    unable to place a form text field and a submit button, so that the
    user gets the freedom to filter the data that he needs.
    So I seeked some advice on this topic at US and I was
    suggested to use XPathApi, after reading the documentation and some
    fiddling, I found a way to extract the data that i was supposed to
    retrieve. but now I face a new problem. since the XML is a bit
    complicating (for me at least). I found difficulties in displaying
    the extracted data to the data grid.
    I have attached the flash source file (v8) and (some what
    similar) the XML files for your reference. would appreciate if
    someone could help me achieve the objective. if you think there is
    another alternative to XPathApi, I willing to try it out.
    Try-out
    Currently the retrieval of the data is working perfectly, for
    example you can perform a query to list all the books that were
    published by 'Wrox' by entering the query in the text field, you
    will see the results in the "Trace" window.
    Source
    TIA

    "lerogke" <[email protected]> wrote in
    message
    news:go8i77$8og$[email protected]..
    > Hi again,
    >
    > i could resolve something, using labelfunction like
    this:
    >
    > private function getValue(item:Object,
    column:DataGridColumn):String{
    > return item.params.param.@value;
    > }
    >
    > This functions gives me all the values of the params but
    consecutive
    > without
    > any space between them.
    >
    > How could i look around each param to put space or some
    text between them
    > to
    > display in Datagrid?
    for each (param in
    item.child('params').child('param').attribute('value)){
    //stuff

  • Load external XML into DataGrid with AS3

    I've really looked hard to find an example/tutorial for
    loading external XML data into a DataGrid component using AS3. The
    code I'm using at the moment has the XML data in the AS code. If
    anyone can point me to a good resource(s) for code or a tutorial
    I'd be very appreciative. It needs to be AS3. ~steve
    Here is the code that is working for internal XML data:
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    stop();
    var emailXML:XML = <emails>
    <email date="06-04-07" code="EMRPAAV" campaign="This is
    the campaign details."/>
    <email date="06-11-07" code="EMRPAAW" campaign="This is
    the campaign details."/>
    <email date="06-18-07" code="EMRPAAX" campaign="This is
    the campaign details."/>
    <email date="06-25-07" code="EMRPAAY" campaign="This is
    the campaign details."/>
    <email date="07-02-07" code="EMRPAAZ" campaign="This is
    the campaign details."/>
    <email date="07-09-07" code="EMRPABA" campaign="This is
    the campaign details."/>
    </emails>;
    var dateCol:DataGridColumn = new DataGridColumn("date");
    dateCol.headerText = "Date";
    dateCol.width = 60;
    var codeCol:DataGridColumn = new DataGridColumn("code");
    codeCol.headerText = "Source Code";
    codeCol.width = 70;
    var campaignCol:DataGridColumn = new
    DataGridColumn("campaign");
    campaignCol.headerText = "Campaign";
    campaignCol.width = 300;
    var myDP:DataProvider = new DataProvider(emailXML);
    emailData.columns = [dateCol, codeCol, campaignCol];
    emailData.width = 440;
    emailData.dataProvider = myDP;
    emailData.rowCount = emailData.length;
    // end code

    Here is how you build it for external XML. in my example am
    using the same xml format that you are using . The xml file called
    "dataGrid.xml"
    import fl.controls.dataGridClasses.DataGridColumn;
    import fl.data.DataProvider;
    import fl.containers.UILoader;
    import fl.data.DataProvider;
    import fl.events.*;
    import flash.xml.*;
    var emailXML:XML;
    var myList:XMLList;
    function parseXML():void
    var url:String = "dataGrid.xml";
    var urlRequest:URLRequest = new URLRequest(url);
    var loader:URLLoader = new URLLoader();
    loader.addEventListener("complete" , loadXML);
    loader.load(urlRequest);
    /*var emailXML:XML = <emails>
    <email date="06-04-07" code="EMRPAAV" campaign="This is
    the campaign details."/>
    <email date="06-11-07" code="EMRPAAW" campaign="This is
    the campaign details."/>
    <email date="06-18-07" code="EMRPAAX" campaign="This is
    the campaign details."/>
    <email date="06-25-07" code="EMRPAAY" campaign="This is
    the campaign details."/>
    <email date="07-02-07" code="EMRPAAZ" campaign="This is
    the campaign details."/>
    <email date="07-09-07" code="EMRPABA" campaign="This is
    the campaign details."/>
    </emails>
    parseXML();
    function loadXML(evt:Event):void
    emailXML = new XML(evt.target.data);
    myDP = new DataProvider(emailXML);
    emailData.dataProvider = myDP;
    var dateCol:DataGridColumn = new DataGridColumn("date");
    dateCol.headerText = "Date";
    dateCol.width = 60;
    var codeCol:DataGridColumn = new DataGridColumn("code");
    codeCol.headerText = "Source Code";
    codeCol.width = 70;
    var campaignCol:DataGridColumn = new
    DataGridColumn("campaign");
    campaignCol.headerText = "Campaign";
    campaignCol.width = 300;
    var myDP:DataProvider;
    emailData.columns = [dateCol, codeCol, campaignCol];
    emailData.width = 440;
    emailData.dataProvider = myDP;
    emailData.rowCount = emailData.length;

  • How2 load xml into datagrid, and create realtime search of datagrid data

    I wanted to be able to load xml data into a datagrid and then create a searchbox that would search in real time (as person typed) from any part of the datagrid.  Does anyone know of any as2.0 component that can do that easily?  If not, i would like to try to tackle this the old fashioned and use this to teach myself as2.0 advanced coding.  can someone point to a step by step or explain how i might get this accomplished?  from loading the xml to putting the node info into the datagrid, to being able to search it in real time.  This is part of a project that i was given that has some serious consequences if i botch it.  Please help!  Thanks so much!

    import fl.controls.DataGrid;
    import fl.controls.ScrollPolicy;
    import fl.data.DataProvider;
    import flash.net.URLLoader;
    import flash.events.Event;
    var dp:DataProvider = new DataProvider();
    var dg:DataGrid = new DataGrid();
    dg.columns=["User","Xp","Rank"];
    addChild(dg);
    var urlloader:URLLoader = new URLLoader();
    urlloader.addEventListener(Event.COMPLETE,loadcompleteF);
    urlloader.load(new URLRequest("whatever.xml"));
    function loadcompleteF(e:Event):void {
        var xml:XML=XML(e.target.data);
        for (var i:int = 0; i < xml..Name.length(); i++) {
            dp.addItem({User:xml..Name[i].User.text(), Xp:xml..Name[i].Xp.text(), Rank:xml..Name[i].Rank.text()});
        dg.dataProvider=dp;

  • Transforming xml and DataGrids

    Hello
    I am reading data from a large xml file. I read it in using
    HTTPService and the result type is "E4X". It contains information
    about items in a warehouse.
    like this
    <Inventory>
    <warehouse name="Texas">
    <chairs count="900"/>
    <tables count="40"/>
    <lamps count="200"/>
    </warehouse>
    <warehouse name="California">
    <chairs count="20"/>
    <tables count="200"/>
    <lamps count="1"/>
    </warehouse>
    </Inventory>
    So far I have been able to show a list of warehouses in a
    mx:List control and then when I select a warehouse (texas in this
    case) I would like to display the list of items and their counts in
    an mx:DataGrid control.
    I can see that I can use selectedItem of the mx:List to
    return the Node for the Texas warehouse like this
    <warehouse name="Texas">
    <chairs count="900"/>
    <tables count="40"/>
    <lamps count="200"/>
    </warehouse>
    But how can I get the data to display in a data grid
    ITEM COUNT
    chairs 900
    tables 40
    lamps 200
    Thanks
    Todd

    Not familiar with stxx, but it should allow you the use of the xsl:strip-space instruction or some equivalent, when the XSLT is applied to the XML for transformation...

  • How to load external XML into DataGrid ??

    Hello ,everybody , I can't load external Xml like this format
    <list>
    <month name="Jan-04" revenue="400263" average="80052">
    <region name="APAC" revenue="46130"/>
    <region name="Europe" revenue="106976"/>
    <region name="Japan" revenue="79554"/>
    <region name="Latin America" revenue="39252"/>
    <region name="North America" revenue="128351"/>
    </month>
    <month name="Feb-04" revenue="379145" average="75829">
    <region name="APAC" revenue="70324"/>
    <region name="Europe" revenue="88912"/>
    <region name="Japan" revenue="69677"/>
    <region name="Latin America" revenue="59428"/>
    <region name="North America" revenue="90804"/>
    </month>
    </list>
    I only can load with node format like this :
    <order>
    <item>
    <menuName>burger</menuName>
    <price>3.95</price>
    </item>
    <item>
    <menuName>fries</menuName>
    <price>1.45</price>
    </item>
    </order>
    Please tell me what am I going to do?
    Thanks!

    I'm stuck on this as well. I've read through the above
    samples and postings and am now feeling really retarded. I thought
    throwing the contents of a simple XML doc into a DataGrid would be
    easy, but I've been trying all morning and no love. Any help is
    appreciated.
    Here the XML --> guides.xml
    <?xml version="1.0" encoding="UTF-8">
    <GuideList title="Current Guides">
    <GuideItem>
    <GuideName>11699240</GuideName>
    <DisplayName>Supercharged Branding
    Program</DisplayName>
    <LinkText>View Downloadable Guide</LinkText>
    <Franchise>Film/TV</Franchise>
    <Property>Cars</Property>
    </GuideItem>
    <GuideItem>
    <GuideName>11721503</GuideName>
    <DisplayName> Packaging & Retail
    Signage</DisplayName>
    <LinkText>View Downloadable Guide</LinkText>
    <Franchise>Film/TV</Franchise>
    <Property>None</Property>
    </GuideItem>
    etc....
    Here's the flex --> GuideListDisplay.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" initialize="guidelist.send()">
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable] private var myData:ArrayCollection;
    private function resultHandler(event:ResultEvent):void {
    myData = event.result.GuideList.GuideItem;
    ]]>
    </mx:Script>
    <mx:HTTPService id="guidelist" url="assets/guides.xml"
    result="resultHandler(event)"/>
    <mx:Panel title="{myData.GuideList.title}"> // 1119
    <mx:DataGrid x="29" y="36" id="Guides"
    dataProvider="{myData.lastresult.GuideList.GuideItem}"> // 1119
    <mx:columns>
    <mx:DataGridColumn headerText="Guide Number"
    dataField="GuideName"/>
    <mx:DataGridColumn headerText="Guide Name"
    dataField="DisplayName"/>
    <mx:DataGridColumn headerText="DisplayText"
    dataField="LinkText"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Panel>
    </mx:Application>
    The lines throw with // 1119 throw a problem notice - 1119:
    Access of possibly undefined property GuideList through a reference
    with static type mx.collections:ArrayCollection.
    GuideListDisplay.mxml Lessons line 17 March 21, 2007 12:53:45 PM
    215
    Please help before hari kari looks like a good option.
    Thanks!

  • XML and DataGrid

    Hi,
    I am working with the XML files and here is my question.
    This is the portion of the XML file
    you can acess my xml file at
    http://pastebin.com/f66fd1ee3
    My XML file keeps changing and the number of action_column
    nodes may vary for each xml file.
    I am trying to display the xml file in the grid using
    http://pastebin.com/f2e57f382
    public function LabelFunc(item:Object,
    column:DataGridColumn): String
    return
    item.action_column.(@column_number==column.dataField).@column_value;
    So is there a way to know how many action_column nodes are
    there and based on that can I do the datagrid dynamically?

    You can get a list of all attributes by calling attributes().
    You can use that info the generate an array of
    DataGridColumns

  • How to bind XML to Datagrid?

    My xml is here:
    <?xml version="1.0"?><ITRequests><CallInfo><id type="INT UNSIGNED">42</id><request_no type="VARCHAR">1313_IT_220520100709</request_no><requester_uid type="VARCHAR">administrator</requester_uid><request_date type="VARCHAR">22-May-2010 07:09:34 PM</request_date><title type="VARCHAR">Printer Installation</title><status type="VARCHAR">Closed</status></CallInfo><CallInfo><id type="INT UNSIGNED">43</id><request_no type="VARCHAR">1314_IT_220520100718</request_no><requester_uid type="VARCHAR">administrator</requester_uid><request_date type="VARCHAR">22-May-2010 07:17:49 PM</request_date><title type="VARCHAR">Software Installation</title><status type="VARCHAR">In Progress</status></CallInfo><CallInfo></ITRequests>
    I don't know how to bind this to a simple datagrid.
    Can someone help me please?
    PS: The data is in a String variable.
    Thanks,
    Nith

    Getting your data in the form a string is a PITA. Can you just use the XML itself, and convert it to an ArrayCollection? Then you could just use an HTTP request, for instance, to retrieve it.
    Anyway, here is the code you need. It also demonstrates using E4X syntax to filter out the root node.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"creationComplete="initApp()"
    >
    <mx:Script>
    <![CDATA[
    import mx.collections.XMLListCollection; 
    import mx.collections.ArrayCollection; 
    private var strData:String = "<?xml version='1.0'?><ITRequests><CallInfo><id type='INT UNSIGNED'>42</id><request_no type='VARCHAR'>1313_IT_220520100709</request_no><requester_uid type='VARCHAR'>administrator</requester_uid><request_date type='VARCHAR'>22-May-2010 07:09:34 PM</request_date><title type='VARCHAR'>Printer Installation</title><status type='VARCHAR'>Closed</status></CallInfo><CallInfo><id type='INT UNSIGNED'>43</id><request_no type='VARCHAR'>1314_IT_220520100718</request_no><requester_uid type='VARCHAR'>administrator</requester_uid><request_date type='VARCHAR'>22-May-2010 07:17:49 PM</request_date><title type='VARCHAR'>Software Installation</title><status type='VARCHAR'>In Progress</status></CallInfo></ITRequests>";[
    Bindable] 
    private var acData:ArrayCollection; 
    private function initApp():void{     getCallInfo();
    private function getCallInfo():void{ 
    //Convert string to XML:
    var sxml:XML = new XML(strData); 
    //Create an ArrayCollection.
    //Just get the 'CallInfo' nodes (ignoring the root node, 'ITRequests'):
    acData =
    new ArrayCollection(new XMLListCollection(new XMLList(sxml..CallInfo)).toArray()); 
    trace(acData);}
    ]]>
    </mx:Script>
    <mx:DataGrid 
    dataProvider="{acData}">
         <mx:columns>
              <mx:DataGridColumn dataField="id" width="50"/>
              <mx:DataGridColumn dataField="request_no" width="180"/>
         </mx:columns></mx:DataGrid>
    </mx:Application>

  • Dynamic XML to Datagrid

    Hello to all,
    I'm not a newbie in Actionscript 3 or in Flash, but I'm starting to use Flex, and maybe there is someting in a small scale missing for waht I want.
    Here's what I have.
    I've made a multiplayer game wich the objective is to answer questions (Math, Physics, Biology, etc...). You must select one of the four answers as fast as you can to end the game, and you will throw new questions to the opponents, if you are really quick.
    This is done, now I have made a simple Flex application that can accept and store the questions to a database with PHP and MySQL. Has this will be used by several teachers to place the questions, it has to be simple. The application stores and retrieves some statistics for the numbers of questions that are stored.
    The second part of this application is to visualize them, and alter them if needed. For that I made a datagrid with a small form beneath it. The objective is to select all questions or select an area and all questions of that area would populate the datagrid. I make a call through a HTTPService to a PHP that would reply XML data, and not a XML file.
    making a raw call for the PHP the answer is correct, and I think that Flex is doing it to, but I don't seem to catch it and place it on the datagrid.
    The XML is like this:
    <list>
         <question>
              <id>
              <ask>
              <resp1>
              <resp2>
              <resp3>
              <resp4>
         </question>
    </list>
    The examples I saw so far only mention the retrieval of an xml file somewhere on the web or localy, never with data in the form of xml. Is it so different?
    Other newbie question... does the command trace, works?
    The code is attached if you care to see it.
    Thanks.
    Leonel
    I a

    never nest named functions. try:
    import flash.events.Event;
    import flash.net.URLRequest;
    import fl.data.DataProvider;
    var agendaXML:XML;
    var agendaXmlLoader: URLLoader = new URLLoader();
    agendaXmlLoader.addEventListener(Event.COMPLETE, agendaLoaded);
    agendaXmlLoader.load(new URLRequest("http://dbmini.local/AZC/createXMLfromAZC.php"));
    function agendaLoaded(evt:Event):void
              agendaXML = new XML(agendaXmlLoader.data);
              var componentProvider:DataProvider = new DataProvider();
              for (var i:uint = 0; i < agendaXML.verhaal.length(); i++)
                        componentProvider.addItem({Datum:agendaXML.verhaal[i].datum , Kop:agendaXML.verhaal[i].kop});
              agenda.dataProvider = componentProvider;
                        agenda.addEventListener(Event.CHANGE, agendaItemKlik);
    function agendaItemKlik(event:Event):void
                                  tekstVlak.text = agendaXML.verhaal[event.target.selectedIndex].tekst;

  • Using xml with datagrid - problem with element attributes ...

    Hi,
    When i try to set the datafield in a DataGridColumn to an
    attribute, ex.: @isPermaLink - the value is not printet in the
    datagrid?
    My code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="feedRequest.send()" layout="absolute"
    backgroundGradientColors="[#808080, #c0c0c0]">
    <mx:HTTPService id="feedRequest" url="
    http://kristianthrane.dk/feed"
    useProxy="false" />
    <mx:Panel x="10" y="10" width="475"
    title="{feedRequest.lastResult.rss.channel.title}" id="panel1"
    height="531">
    <mx:DataGrid id="dgPosts" x="20" y="20" width="100%"
    dataProvider="{feedRequest.lastResult.rss.channel.item.guid}"
    height="100%">
    <mx:columns>
    <mx:DataGridColumn headerText="Lande"
    dataField="@isPermaLink" />
    </mx:columns>
    </mx:DataGrid>
    </mx:Panel>
    </mx:Application>
    I hope someone has a tip ....
    Best regards,
    Kristian Thrane

    Hi Kristian,
    I'm with some problems, a bit alike yours, but from what I've seen, I would recomend you to see type errors...does the atribute "isPermaLink" inside the "guid" tag, or "title" tag?
    My problem is the opposite of what you have... I can place tag attributes in a datagrid, but I can't put in the same Datagrid the tag value. But I have no choice since the feed comes from a public webservice.
    My feed is:
    <search ver="3.0">
    <loc id="BRXX1094" type="1">Aveiro, Brazil</loc>
    <loc id="POXX0006" type="1">Aveiro, Portugal</loc>
    </search>
    <mx:DataGrid x="10" y="53" width="365" id="dgLocation" dataProvider="{wSearch.lastResult.loc}" itemClick="callService(event);">
    <mx:columns>
           <mx:DataGridColumn headerText="Localidade" dataField="loc"/> //This doesn't work
           <mx:DataGridColumn headerText="Referência" dataField="@id"/> //This does
    </mx:columns>
    </mx:DataGrid>
    Hope it give you any ideas.
    Beste regards
    Leonel

  • Problem With XML and DataGrid)

    Hi,
    I do have a question how to get my XML data in the appropriate way into my DataGrid. I wrote a labelFunction to get the data into the grid but I still have the problem that the length of the DataGrid depends on the dataProvider and I can't find a way to specify that it should depend on a child object of the dataProvider.
    If you look at the structure of the XML file you can see that for every date a couple of hours exist (normally 24 ) and measurements coming in every hour. So, naturally I would like to show the measurements in connection to the hour. The column 'Date' and 'Time' will be merged anyway to something like '23/2:10-11'. So, if it is easier to combine these values first and create that way a unique date I would be also happy.
    However, the XML file and the Flex code you find at http://www2.dmu.dk/thob/Station_Nord/srcview/index.html and the Flex application you find at http://www2.dmu.dk/thob/Station_Nord/Station_Nord.html.
    Thanks for your help in advance,
    Thomas

    I don't want to analyze that example. Are you asking how to
    get an id or some other value when you select a row in a datagrid?
    When you select an item in any list-based control, the
    control's selectedItem properety contains a reference to the
    dataProvider item object for that selected item. You can access any
    property that is present in that object:
    var sId:String = myDataGrid.selectedItem.myIDProperty;
    If I have misunderstood, please restate your question.
    Tracy

  • XML for DataGrid

    I suck at this I guess...
    Although I love and enjoy Flash and AS3.0 I just end up
    getting stuck everytime I solve a problem..
    I've tried out different solutions for my problems but when I
    try to making it work on my problems it won't work. It work at some
    point but fail to keep my problems away.
    After having loaded a xml-file I want the contents to be
    assigned to a DataGrid in the different columns that I need.
    And, if possible, I want to sort the contents first by column
    A and then by column B.
    But how do I assign the xml-contents/data to the DataGrid?
    And how do I sort the data/contents in the DataGrid??
    Thanks in advance.

    I've tried something similar and it work fine.
    However, the problem seem to occure when I want to import a
    xml-file.
    I've copied and pasted your code into an xml-file, loaded it
    and made sure it worked.
    But when I try to load my own xml-file into flash the data
    won't display in the grid.
    I've made the changes I needed (changed the name of the the
    objects, etc. to fit the data I want to display in the grid) but it
    just won't work.
    Since I've tested your xml-code in an external xml-file I
    would assume it would also work with the xml-file I want to load
    into the flash.
    So, what the heck is wrong??
    Here's my code for loading and trying to display the XML in
    flash:
    import fl.data.DataProvider;
    import fl.controls.DataGrid;
    import fl.controls.dataGridClasses.DataGridColumn;
    var myUrlLoader:URLLoader = new URLLoader();
    var myUrlReq:URLRequest = new
    URLRequest("exportdisplay_bildatatest.xml");
    myUrlLoader.load(myUrlReq);
    myUrlLoader.addEventListener(Event.COMPLETE, dataOK);
    function dataOK(e:Event):void{
    var data:XML = new XML(myUrlLoader.data);
    var dp:DataProvider = new DataProvider(data);
    var dg:DataGrid = new DataGrid();
    dg.setSize(400, 300);
    var col:DataGridColumn;
    col = dg.addColumn("Årsmodell");
    col.dataField ="Arsmodell";
    col = dg.addColumn("Merke");
    col.dataField ="Merke";
    col = dg.addColumn("Modell");
    col.dataField ="Modell";
    col.sortable=false;
    dg.dataProvider = dp;
    addChild(dg);
    PS!
    The xml-file I want to display is an xml-file that is
    generated each afternoon and uploaded to a server.
    Could it be that the problem lies within this proscess??
    I've checked the file and it seem OK...
    And when I trace it in flash the contents displays in the
    Output-box.

Maybe you are looking for

  • HT1386 icloud messes up itunes sync on ipod

    Since using icloud, my ipod no longer appears in itunes as a device. How can I repair this? Certains apps (e.g., Goodreader) don't work without itunes.

  • A/r down payment request/invoice

    Hi Can anybody give a link for Documentation Resource Centre, on a/r down payment request/invoice in sap 2007 B Thanks

  • Deploy Applet

    I followed the deployment instructions in book 'Oracle JDeveloper'.--However, I am using JBuilder deployment wizard. 1. extract borland.jbcl.control.image and borland.jbcl.control.view.image to my project 2. to include all dependency classes 3. I als

  • BI Beans under OC4J with a lot of errors -- !HEPL!

    All I have built some dimensions and cubes through BI Beans . but once all of them finished it will drop into an error. when I request a Presentation object(cross table) through web client,the console shows following: Fri Jun 18 21:49:21 CST 2004 TRA

  • Drawing a line

    Is it possible to just draw a few straight lines in FCP pro 5.0? Thanks - Alessandra