IdleSun's Weblog

September 30, 2008

Embed a XML file in Flex

Filed under: Flex,XML — idlesun @ 6:40 pm

Although you can embed XML string in the Flex code, you would want to make it as a seperate XML file and use it. So that you can get the benefits of editing XML data using XML editor. One of the easist way I found to embed external XML file is use [Embed] metadata tag. Here is the sample code:

var testXml:Class;

function init(): void {
  var xml:XML = as XML;;

It is really simple, isn’t it? However, this technique has a couple of limitations like:

  • XML file can not have a XML declaration line like “<?xml version=”1.0″ encoding=”utf-8″?>”
  • To use international characters, save XML file in Unicode not in UTF-8

Sample Source: click right button on this link and select “Save Link As” to download the file and rename its extension to “zip”



  1. […] XML 임베딩하기 In ? on 2009/08/18 at 11:46 pm 원문링크: […]

    Pingback by XML 임베딩하기 « Strigid's Blog — August 18, 2009 @ 2:46 pm | Reply

  2. A lot of of folks blog about this matter but you wrote down some true words.

    Comment by snalodeenefly — November 25, 2009 @ 5:35 pm | Reply

  3. […] can load an xml config file as follows: (Extract from the cairngorm serviceLocator, based on an Idlesun’s post) <cairngorm:ServiceLocator xmlns:mx="; […]

    Pingback by Cairngorm with config file « 3 character abbreviation — January 12, 2010 @ 4:00 pm | Reply

  4. […] 원문 링크. […]

    Pingback by XML 임베딩하기 — December 4, 2010 @ 10:20 am | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

%d bloggers like this: