Expand my Community achievements bar.

Make string from XML into link??

Avatar

Former Community Member

I am using httpServices to import data from an XML file. The data is returned as a string but I need it to be a clickable link. Please help.

here is my simple code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="myService.send()">
   
    <mx:HTTPService id="myService" url="data/infocenter_links.xml"/>
   
    <mx:DataGrid width="300" dataProvider="{myService.lastResult.links}" />
</mx:Application>

Here is a sample of the XML....

<?xml version="1.0"?>
<links>
<link>url:www.mmprint.com</link>


</links>

any help is greatly appreciated!!!

2 Replies

Avatar

Former Community Member

Use a LinkButton as the itemRenderder for that DataGrid column. See FB3 help sys for info on LinkButton and creating itemRenderer for DG.

Avatar

Level 1

Another option is to create a custom renderer and use the htmltext attribute of a text control, like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" height="100%" width="100%" horizontalScrollPolicy="off">
    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.dataGridColumn;
           
            [Bindable] protected var myURL:String;
            override public function set data(value:Object):void {
                myURL= '<a href="http://www.example.com/myPage.php?pageID="'+value.id+'" target="_blank">'+value.name+'</a>';
            }
        ]]>
    </mx:Script>
    <mx:Text htmlText="{myURL}" height="100%" width="100%" />
</mx:Canvas>