亲宝软件园·资讯

展开

Flex 读取xml Flex 读取xml文件的方法

人气:1
想了解Flex 读取xml文件的方法的相关内容吗,在本文为您仔细讲解Flex 读取xml的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Flex,读取,xml,下面大家一起来学习吧。
方法一:
复制代码 代码如下:

private function readxml1():void{
var xmlfile:file = new file("file path");
var stream:filestream = new filestream();
stream.open(xmlfile, filemode.read);
var xml:xml = xml(stream.readutfbytes(stream.bytesavailable));
stream.close();
}

方法二:
复制代码 代码如下:

private function readxml2():void{
var urlrequest:urlrequest = new urlrequest("xml file path");
var urlloader:urlloader = new urlloader(urlrequest);
urlloader.addeventlistener(event.complete,completehandler);
}

private function completehandler(event:event):void{
var xml:xml = new xml(event.target.data);
trace(xml);
}

flex写xml的方法:
复制代码 代码如下:

public static function writexmlfile(xml:xml):void{
var stream:filestream = new filestream();
var xmlfile:file = new file("file path");
var outputstring:string = '\n';
outputstring += xml.toxmlstring();
outputstring = outputstring.replace(/\n/g, file.lineending);
stream = new filestream();
stream.open(xmlfile, filemode.write);
stream.writeutfbytes(outputstring);
stream.close();
}

加载全部内容

相关教程
猜你喜欢
用户评论