Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Flash Development
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-28-2009, 01:55 AM
  #1
vishal3184
Aspirant (Level 2)
 
Join Date: Jul 2009
Posts: 19
iTrader: (0)
vishal3184 is an unknown quantity at this point
Formatting xml file using eXtensible stylesheet language in AS 3.0

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">

<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.
vishal3184 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 01:29 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.