Flash as3 ×Ô¶¨ÒåReadXMLÀà¶ÁÈ¡xml ¡¾Ô´´¡¿
¼òµ¥µÄÀ࣬¼ò»¯×Ô¼º¶ÁÈ¡xmlµÄ¹ý³Ì
ReadXML.as
package
{
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.System;
import flash.events.EventDispatcher;
public class ReadXML extends Sprite
{
private var xmlURL:String ;
private var xmlRequest:URLRequest;
private var xmlLoader:URLLoader;
private var _xmlText:XML;
private var isComplete:Boolean=false;
public function ReadXML (_xmlURL:String)
{
System.useCodePage = true;
xmlURL = _xmlURL;
xmlRequest = new URLRequest(xmlURL);
xmlLoader = new URLLoader(xmlRequest);
xmlLoader.addEventListener (Event.COMPLETE,xmlLoadHandler);
}
private function xmlLoadHandler (e:Event)
{
_xmlText = XML(xmlLoader.data);
_xmlText.ignoreWhitespace = true;
this.dispatchEvent(new Event("complete"));
}
public function get xmlText():XML
{
return _xmlText;
}
}
}
ÎĵµÀà
var ppp:ReadXML=new ReadXML("simple.xml");
ppp.addEventListener("complete",okHandler)
//ÕìÌýxml¶ÁÈ¡Íê±ÏÁËûÓУ¬×Ô¶¨Òå¹ã²¥Æ÷complete
function okHandler(e:Event)
{
trace(ppp.xmlText.list[0].@id);
trace(ppp.xmlText.list[1].title)
}
Ïà¹ØÎĵµ£º
Ò» DOM ÒÔÏ´úÂëÓÃDOMÊÇÉú³ÉÒ»¸öXMLÎĵµ
package xml;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
imp ......
<embed id="focus_flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://image2.sina.com.cn/bj/zonghe/pixviewer.swf" width="180" height="200" type="application/x-shockwave-flash" wmode="opaque" bgcolor="#FDD248" flashvars="pics=http://static8.photo.sina.com.cn/orignal/4569dfb ......
Ò»¡¢²âÊÔÓõÄem.xml
<?xml version="1.0" encoding="GB2312"?>
<EW cmd="login" mod="Login" version="6.0">
<Source uns="" type="user"/>
<Username>zhangzhiyun@hp</Username>
<Password>111111</Password> ......
package com.flxx.docUrl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jd ......
1 ËùÓÐµÄ .java|.jsp|.html|.xml Ô´Îļþ¾ùʹÓÃutf-8±àÂë¸ñʽ±£´æµ½ÏµÍ³´ÅÅÌ¡£
È磺ÔÚEclipseÖбà¼Îļþ£¬Ñ¡ÖÐÎļþ´ò¿ªÓÒ¼ü²Ëµ¥Ñ¡ÔñÊôÐÔ£¬½«Îı¾Îļþ±àÂëÉèÖÃΪÆäËû²¢Ñ¡ÔñUTF-8£»Ò²¿ÉÒÔÔÚ
Eclipse——Ê×Ñ¡Ïî——³£¹æ——ÄÚÈÝÀàÐÍÖÐÉèÖø÷ÖÖÎļþµÄȱʡ±àÂ룬ÕâÑùÒÔºóËùÓеÄÎı¾Îļþ¶¼Ê¹ÓÃÍ³Ò ......