PDA

View Full Version : Communicating with XML file on web server


Muncey
04-05-2008, 06:07 PM
Ok i have hosting and i'm just wondering if it is possible to connect to my host and drag information directly from an XML file on the site?

I'm pretty clueless atm on how to do this. I did think of using URL loader but then i would need to use php scripts to get the XML from it so it wouldn't work in AIR.

Really confused...

Thanks in advance!

aftershock
04-16-2008, 12:09 PM
What are you working in Flash, Flex or HTML ?

If you want to get XML from your server and you are using Flex say, you can call the hosted XML file using a URLRequest and URLLoader:

var myXML:XML = new XML();
var XML_URL:String = "http://www.example.com/Sample3.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(evtObj:Event) {
myXML = XML(myLoader.data);
trace("Data loaded.");
}


If you are using HTML then you will need to utilise JavaScript and possibly AJAX to call any external data. Look at jQuery, PrototypeJs or MooTools as a start.