Using Action script 3 Get required tag form XML and required children tag?
I have a XML schema.I want to read only table tag and its geometery tag using action script3 code.Any Idea.
<table name="TableBase 1" id="TableBase3010" overflow="false" direction="lr-tb" suppress-empty-lines="false">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="117" top="102"/>
<size width="341" height="80"/>
<transform rotation="0"/>
</geometry>
<columns number-of-columns="1" gutter="0" align-bottoms="false"/>
开发者_如何学JAVA <header>
<row>
<cell>
<objects>
<text name="SingleLineText3081" id="ElxSingleLineText3081">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="0" top="0"/>
<size width="341" height="20"/>
<transform rotation="0"/>
</geometry>
<content value="Text"/>
</text>
</objects>
</cell>
</row>
</header>
<body>
<row>
<cell>
<objects>
<text name="SingleLineText3150" id="ElxSingleLineText3150">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="0" top="0"/>
<size width="341" height="20"/>
<transform rotation="0"/>
</geometry>
<content value="Text"/>
</text>
</objects>
</cell>
</row>
</body>
<footer>
<row>
<cell>
<objects>
<text name="SingleLineText3279" id="ElxSingleLineText3279">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="0" top="0"/>
<size width="341" height="20"/>
<transform rotation="0"/>
</geometry>
<content value="Text"/>
</text>
</objects>
</cell>
</row>
</footer>
</table>
THANKS IN ADVANCE !!!!!!!
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
<fx:XML id="treeDP">
<table name="TableBase 1" id="TableBase3010" overflow="false" direction="lr-tb" suppress-empty-lines="false">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="117" top="102"/>
<size width="341" height="80"/>
<transform rotation="0"/>
</geometry>
<columns number-of-columns="1" gutter="0" align-bottoms="false"/>
<header>
<row>
<cell>
<objects>
<text name="SingleLineText3081" id="ElxSingleLineText3081">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="0" top="0"/>
<size width="341" height="20"/>
<transform rotation="0"/>
</geometry>
<content value="Text"/>
</text>
</objects>
</cell>
</row>
</header>
<body>
<row>
<cell>
<objects>
<text name="SingleLineText3150" id="ElxSingleLineText3150">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="0" top="0"/>
<size width="341" height="20"/>
<transform rotation="0"/>
</geometry>
<content value="Text"/>
</text>
</objects>
</cell>
</row>
</body>
<footer>
<row>
<cell>
<objects>
<text name="SingleLineText3279" id="ElxSingleLineText3279">
<style-ref name="default"/>
<geometry size="absolute" position="absolute">
<location left="0" top="0"/>
<size width="341" height="20"/>
<transform rotation="0"/>
</geometry>
<content value="Text"/>
</text>
</objects>
</cell>
</row>
</footer>
</table>
</fx:XML>
</fx:Declarations>
<fx:Script>
<![CDATA[
protected function onClick(event:Event):void
{
for each(var item:XML in treeDP){
textArea1.text=item;
textArea2.text=item.child("geometry");
}
}
]]>
</fx:Script>
<s:Button id="Click" click="onClick(event)" x="1" y="57" label="Click"/>
<mx:TextArea id="textArea1" x="95" y="17" width="456" height="335"/>
<mx:TextArea id="textArea2" x="559" y="17" width="369" height="336"/>
</s:Application>
Let us assume your XML is stored in a variable called 'xml'
var xml:XML;
Now xml
will store your tag and you can get the geometry details as XMLList
var xmlList:XMLList = xml.child("geometry")
trace(xml.child("geometry")[0].toXMLString());//<location left="117" top="102"/>
trace(xml.child("geometry")[1].toXMLString());//<size width="341" height="80"/>
精彩评论