<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kimkijeung.com &#187; ECMAScript</title>
	<atom:link href="http://kimkijeung.com/tag/ecmascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://kimkijeung.com</link>
	<description>Interactive development,flash,Actionscript</description>
	<lastBuildDate>Wed, 25 Aug 2010 09:12:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<image>
			<title>Kimkijeung.com</title>
			<url>http://kimkijeung.com/blog/wp-content/uploads/2009/12/index.gif</url>
			<link>http://kimkijeung.com</link>
			<width></width>
			<height></height>
			<description>Interactive development,flash,Actionscript</description>
		</image>		<item>
		<title>E4X XML API in AS3.0</title>
		<link>http://kimkijeung.com/2006/06/04/148/</link>
		<comments>http://kimkijeung.com/2006/06/04/148/#comments</comments>
		<pubDate>Sun, 04 Jun 2006 11:47:32 +0000</pubDate>
		<dc:creator>vkimone</dc:creator>
				<category><![CDATA[Flash-AS3.0]]></category>
		<category><![CDATA[AS3.0]]></category>
		<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://localhost:8888/blog/?p=148</guid>
		<description><![CDATA[ActionScript 3.0 features a full implementation of ECMAScript for XML (E4X), recently standardized as ECMA-357. E4X offers a natural, fluent set of language constructs for manipulating XML. Unlike traditional XML parsing API’s, E4X makes XML feel like a native data type of the language. E4X streamlines the development of applications that manipulate XML by drastically [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #8e8e8e;">ActionScript 3.0 features a full implementation of ECMAScript for XML (E4X), recently standardized as ECMA-357. E4X offers a natural, fluent set of language constructs for manipulating XML. Unlike traditional XML parsing API’s, E4X makes XML feel like a native data type of the language. E4X streamlines the development of applications that manipulate XML by drastically reducing the amount of code needed. You can learn more about the E4X specification here: </span></p>
<p><a class="external" rel="nofollow" href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-357.pdf" target="mm_window">http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-357.pdf</a><br />
AS3.0 에 새롭게  E4X(ECMAScript for XML) 를 지원한다. E4X 는 XML을 관리하기 위한 모든 언어를 제공한다. 이젠 플래시에서도 제한된 xml 에서 탈피해 좀 더 효율적인 코드작성이 가능하다.</p>
<p>따로 파서를 만들어 쓰고 있지만  워낙 xml 쓰는 방법이 다양해 정형화된 방법을 찾는데 쉽지 않았다.</p>
<p>시간이 되면 AS2.0 방식도 아래와 같은 방법으로 사용해서 파서를 따로 만들어 쓰는것도 좋은 방법인듯 싶다.</p>
<p>AS3.0 에서부터는 xml 노드 구조만 알면 이제부터 아주 쉽게 데이타 파싱이 가능하다.</p>
<p>내장되어있는 파서인 만큼 특별한 코드가 필요없다.</p>
<p>xml 데이타를 통해 노드구조를 접근하면 파서가 알아서 데이타를 추출해 준다. 또한 조건 검색을 통한 데이타 검색도 가능하다.</p>
<p>AS3.0 &#8230;.. 암튼 무척 기대된다.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">&nbsp;
<span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> flash.util.<span style="color: #004993;">trace</span>;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> E4XExample extends <span style="color: #004993;">MovieClip</span> <span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> E4XExample<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> employees<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>staff<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			 <span style="color: #000000; font-weight: bold;">&lt;</span>employee id=<span style="color: #990000;">&quot;1&quot;</span> <span style="color: #004993;">status</span>=<span style="color: #990000;">&quot;active&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			 <span style="color: #000000; font-weight: bold;">&lt;</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>Christian Cantrell<span style="color: #000000; font-weight: bold;">&lt;/</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			 <span style="color: #000000; font-weight: bold;">&lt;</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>CEO<span style="color: #000000; font-weight: bold;">&lt;/</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			 <span style="color: #000000; font-weight: bold;">&lt;</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">12</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2001</span><span style="color: #000000; font-weight: bold;">&lt;/</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			 <span style="color: #000000; font-weight: bold;">&lt;/</span>employee<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;</span>employee id=<span style="color: #990000;">&quot;2&quot;</span> <span style="color: #004993;">status</span>=<span style="color: #990000;">&quot;active&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>Danny Dura<span style="color: #000000; font-weight: bold;">&lt;/</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>Developer<span style="color: #000000; font-weight: bold;">&lt;/</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">9</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2003</span><span style="color: #000000; font-weight: bold;">&lt;/</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			         <span style="color: #000000; font-weight: bold;">&lt;/</span>employee<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;</span>employee id=<span style="color: #990000;">&quot;3&quot;</span> <span style="color: #004993;">status</span>=<span style="color: #990000;">&quot;contractor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>Mike Chambers<span style="color: #000000; font-weight: bold;">&lt;/</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>Director<span style="color: #000000; font-weight: bold;">&lt;/</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">11</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">1999</span><span style="color: #000000; font-weight: bold;">&lt;/</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;/</span>employee<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;</span>employee id=<span style="color: #990000;">&quot;4&quot;</span> <span style="color: #004993;">status</span>=<span style="color: #990000;">&quot;active&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>Scott Fegette<span style="color: #000000; font-weight: bold;">&lt;/</span>name<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>President<span style="color: #000000; font-weight: bold;">&lt;/</span>position<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			  <span style="color: #000000; font-weight: bold;">&lt;</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">4</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">1889</span><span style="color: #000000; font-weight: bold;">&lt;/</span>startDate<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;/</span>employee<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;/</span>staff<span style="color: #000000; font-weight: bold;">&gt;</span>;
			<span style="color: #009900;">//All employees' names (as an XMLList)</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// The first employee's name</span>
			<span style="color: #009900;">// Christian</span>
&nbsp;
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span>.<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// All IDs (as an XMLList)</span>
			<span style="color: #009900;">// 1234</span>
&nbsp;
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.@id<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// The name of the employee with an ID of 2</span>
			<span style="color: #009900;">// Danny Dura</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.@id==2.<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// The employee with the name &quot;Christian Cantrell&quot;</span>
			<span style="color: #009900;">// Returns an XMLList</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.<span style="color: #004993;">name</span>==<span style="color: #990000;">&quot;Christian Cantrell&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// Employee #3's start date</span>
			<span style="color: #009900;">// 8/11/1999</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.@id==3.startDate<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// All contractors (as XMLList)</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.@<span style="color: #004993;">status</span>==<span style="color: #990000;">&quot;contractor&quot;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// All contractors' names (as XMLList)</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.@<span style="color: #004993;">status</span>==<span style="color: #990000;">&quot;contractor&quot;</span>.<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// All employees with IDs less than or equal to 2</span>
			<span style="color: #009900;">// Returns an XMLList</span>
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>employees.employee.@id<span style="color: #000000; font-weight: bold;">&lt;</span>=<span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #009900;">// Iterate through all start dates</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> item<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span>;
			<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span>item <span style="color: #0033ff; font-weight: bold;">in</span> employees..startDate<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>item<span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://kimkijeung.com/2006/06/04/148/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
