flex处理xml

<?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" minWidth="955" minHeight="600">
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			[Bindable]
			private var xml:XML = <a>
				<b c="这是b1的属性">
					这是b1的值
				</b>
				<b c="这是b2属性">
					这是b2值
				</b>
			</a>;
			
			[Bindable]
			private var xmllist:XMLList = xml.b;
		]]>
	</fx:Script>
	<mx:TextArea text="{xml.toString()}" height="122"/>
	<mx:TextArea text="{xmllist.toString()}" height="122" y="130"/>
	<mx:Button label="b1值" click="Alert.show(xml.b[0]);" x="94" y="268"/>
	<mx:Button label="b1属性" click="Alert.show(xml.b[0].@c);" x="10" y="268"/>
	<mx:Button label="b2值" click="Alert.show(xml.b[1]);" x="94" y="298"/>
	<mx:Button label="b2属性" click="Alert.show(xml.b[1].@c);" x="10" y="298"/>
	<mx:Button label="xml的长度" click="Alert.show(xml.length());" x="26" y="328"/>
	<mx:Button label="b的长度" click="Alert.show(xml.b.length());" x="26" y="358"/>
	<mx:Button label="xmllist的长度" click="Alert.show(xmllist.length());" x="26" y="388"/>
</s:Application>


 

你可能感兴趣的:(flex处理xml)