View Full Version : display data from xml generated by php
vasigaran
02-15-2009, 08:40 AM
Dear Friends,
iam new to Flex, i know Flash and AIR very well. Now i started working on Flex3 builder.
I am creating a stand alone application, which has to show the check or Text boxes with a dynamic labels from the xml page which was generated by a php code.
kindly help me to do this.
Thanks and Advance,
Vasigaran :(
fx.barrett
02-15-2009, 10:20 AM
A really simple example would be this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
[Bindable]
private var _data:XML = <root>
<options>
<name>Your Label 1</name>
<name>Your Label 2</name>
<name>Your Label 3</name>
<name>Your Label 4</name>
</options>
</root>;
]]>
</mx:Script>
<mx:VBox horizontalCenter="0" verticalCenter="0">
<mx:Repeater id="myRepeater" dataProvider="{_data.options.name}">
<mx:CheckBox label="{myRepeater.currentItem}"/>
</mx:Repeater>
</mx:VBox>
</mx:Application>
This might not be what you are exactly looking for ( since I don't know how you want the application built ) but it should be a starting point. The XML structure I created is there do demonstrate how you'd handle an XML structure once it comes back from PHP well formatted.
vasigaran
02-15-2009, 11:26 AM
Dear Mr.fx.barrett,
Thks a lot. I need to give the xml path as
<mx:HTTPService id="xmlid" url="http://v5.test.arabianbusiness.com/testing/flex/flexdb.xml"/>
like url address. i tried this it is not working. as XML it is working. i need to put my labels as dynamic. this xml page may be generated by php.
pls help me..
Thanks in Advance,
Vasigaran
vasigaran
02-16-2009, 07:42 AM
Dear Mr. fx.barrett,
thks 4 the code and help. i tried to run this in Flex builder3, it was not running. i tried to to compile at flex3sdk, it is giving swf output. But i need to run in flex builder3. pls help me...
Thanks and Regards,
Vasigaran
------------------------------------------------------------------------
A really simple example would be this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
[Bindable]
private var _data:XML = <root>
<options>
<name>Your Label 1</name>
<name>Your Label 2</name>
<name>Your Label 3</name>
<name>Your Label 4</name>
</options>
</root>;
]]>
</mx:Script>
<mx:VBox horizontalCenter="0" verticalCenter="0">
<mx:Repeater id="myRepeater" dataProvider="{_data.options.name}">
<mx:CheckBox label="{myRepeater.currentItem}"/>
</mx:Repeater>
</mx:VBox>
</mx:Application>
This might not be what you are exactly looking for ( since I don't know how you want the application built ) but it should be a starting point. The XML structure I created is there do demonstrate how you'd handle an XML structure once it comes back from PHP well formatted.
wvxvw
02-16-2009, 09:20 AM
<?xml version="1.0" encoding="utf-8"?>
<!-- SimpleService -->
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
private function resultHandler(event:ResultEvent):void
{
dp = event.result.node;
}
private function faultHandler(event:FaultEvent):void
{
faultText.text = event.fault;
}
]]>
</mx:Script>
<mx:HTTPService
id="service"
resultFormat="e4x"
url="http://localhost/simpleService.php"
result="resultHandler(event)"
fault="faultHandler(event)"/>
<mx:XMLList id="dp"/>
<mx:ComboBox dataProvider="{dp}"/>
<mx:Button label="Connect"
click="{service.send()}"/>
<mx:Text id="faultText"/>
</mx:Application>
<?php
$heredoc = <<<HEREDOC
<data>
<node attr="1">some text 1</node>
<node attr="2">some text 2</node>
<node attr="3">some text 3</node>
<node attr="4">some text 4</node>
</data>
HEREDOC;
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->loadXML($heredoc);
print $doc->saveXML();
?>
sethu
02-16-2009, 09:36 AM
how do i workout in ASP?
Here is my ASP code.I have a table called Mas_City and it contains City name & city_code.I formed the result as XML format.
<%
Connstr = "Provider=SQLOLEDB;Data Source=192.168.0.50;Database=HRM_Trainee;Network Library=DBMSSOCN;UID=sa;Pwd=ikonford"
set conn=server.Createobject("ADODB.Recordset")
conn.open "Select * From mas_city", connstr
dim mxmlStr, mxmLoop
mxmlstr=""
accessSqlArray = conn.GetRows()
If IsArray(accessSqlArray) Then
mxmlstr="<City>"
For mxmLoop = 0 to UBound(accessSqlArray,2)
mxmlStr = mxmlStr & "<Cinfo><city_code>" & accessSqlArray(0,mxmLoop) & "</city_code><city_name>" & accessSqlArray(1,mxmLoop) & "</city_name></Cinfo>" & VBCRLF
Next
mxmlStr = mxmlStr & "</City>"
REsponse.write mxmlStr
End If
%>
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.