# Formatting xml file using eXtensible stylesheet language in AS 3.0

**URL:** <https://forum.kirupa.com/t/formatting-xml-file-using-extensible-stylesheet-language-in-as-3-0/299126>\
**Category:** flash\
**Created:** [October 30, 2009, 8:11am UTC](https://forum.kirupa.com/t/formatting-xml-file-using-extensible-stylesheet-language-in-as-3-0/299126 "2009-10-30T08:11:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishal3184](https://avatars.discourse-cdn.com/v4/letter/v/94ad74/32.png) [@vishal3184](https://forum.kirupa.com/u/vishal3184)\
**Post date:** [October 30, 2009, 8:11am UTC](https://forum.kirupa.com/t/formatting-xml-file-using-extensible-stylesheet-language-in-as-3-0/299126/1 "2009-10-30T08:11:42Z")

</div>

Hi Everyone,

I have successfully loaded xml file into flash AS 3.0.

Now i need to format the xml file using the eXtensible stylesheet language (xsl) in flash environment.

Can anyone tell me how to format the xml using xsl.

Below is action script code for loading xml  
\*\*  
import fl.controls.TextArea;

var xml:XML;

var urlRequest:URLRequest = new URLRequest(“cd\_catalog.xml”);

var urlLoader:URLLoader = new URLLoader();  
urlLoader.addEventListener(Event.COMPLETE, urlLoader\_complete);  
urlLoader.load(urlRequest);

var textArea:TextArea = new TextArea();  
textArea.move(5, 5);  
textArea.setSize(stage.stageWidth - 10, stage.stageHeight - 10);  
addChild(textArea);

function urlLoader\_complete(evt:Event):void {  
xml = new XML(evt.currentTarget.data);  
textArea.text = xml.toXMLString();  
}\*\*

And here is my xml file

\*\*\<?xml version=“1.0” encoding=“utf-8”?\>  
\<?xml-stylesheet type=“text/xsl” href=“product.xsl”?\>  
\<productdata\>  
\<product\>  
\<name\>apple\</name\>  
\<description\>it’s tasty… :-)\</description\>  
\<price\>Rs. 10\</price\>  
\</product\>  
\<product\>  
\<name\>mango\</name\>  
\<description\>it’s yellow…\</description\>  
\<price\>Rs. 20\</price\>  
\</product\>  
\</productdata\>  
\*\*

And here is my xls file

\*\*\<?xml version=“1.0” encoding=“ISO-8859-1”?\>  
\<!-- Edited by XMLSpy® --\>  
\<xsl:stylesheet version=“1.0” xmlns:xsl=“[http://www.w3.org/1999/XSL/Transform](http://www.w3.org/1999/XSL/Transform)”\>

\<xsl:template match="/"\>  
\<html\>  
\<body\>  
\<h2\>My Product Data\</h2\>  
\<table border=“1”\>  
\<tr bgcolor="#9acd90"\>  
\<th\>Product Title\</th\>  
\<th\>Description\</th\>  
\<th\>Price\</th\>  
\</tr\>  
\<xsl:for-each select=“productdata/product”\>  
\<tr\>  
\<td\>\<xsl:value-of select=“name”/\>\</td\>  
\<td\>\<xsl:value-of select=“description”/\>\</td\>  
\<td\>\<xsl:value-of select=“price”/\>\</td\>  
\</tr\>  
\</xsl:for-each\>  
\</table\>  
\</body\>  
\</html\>  
\</xsl:template\>  
\</xsl:stylesheet\>\*\*

Thanks in advance.
