加载外部xml解析IP

//LoadXml---------------------------------------------------------
var LoadXML:XML = new XML();
var exxml:XML;//set variable exxml as xml data type
var loader:URLLoader = new URLLoader();//set variable  loader as URLLLoader data type
var requestt:URLRequest=new URLRequest("http://webservice.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx/getGeoIPContext");
//set variable  requestt as URLRequest data type with parameter(location of the external xml file)
loader.load(requestt);

loader.addEventListener(Event.COMPLETE, image_num_fromXML_OnComplete);

//----------------------------------------------------------------------


function image_num_fromXML_OnComplete(event:Event):void {

	
	loader.removeEventListener(Event.COMPLETE, image_num_fromXML_OnComplete);
	exxml=new XML(loader.data);
	var ns:Namespace=exxml.namespace()
	
   var t:TextField=new TextField();
   t.text=loader.data
   t.x=100
   t.y=100
   t.width=1000
   t.height=1000
   addChild(t)
trace(exxml.ns::string[0])
   
 txt.text= "你的ip是"+exxml.ns::string[0]+"你来自" +exxml.ns::string[1]

}

 

你可能感兴趣的:(xml解析)