Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Can I load xml file from a url on an iphone app?

Guest
Jul 20, 2011 Jul 20, 2011

I've seen a question similar to this, but the xml file was local. I need to do a URLRequest on an http address if it's possible.

I know the as3 is good as it works when I export to swf and chuck it live somewhere, but exported to ios it doesn't. No errors when compiling, so impossible to debug.

I have a crossdomain on the website that generates the xml to allow everything access, and I've both added Security.allowInsecureDomain("*");  and Security.allowDomain("*"); in the flash file. An the url is definitely correct and has http:// at the beginning.

I'm at a bit of a loss as to what to try next. So any suggestions are very welcome!

Thanks

Kev

TOPICS
Development
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 20, 2011 Jul 20, 2011

Can't you use a debug version on your device?

Are you trying to load a xml file or you query a php (for example) page that return an xml?

I did both, and both worked on iPad.

What are you doing with the xml once you received it? What happens on the iOS device?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 21, 2011 Jul 21, 2011

Hello,

Thankyou for your response.

Could you suggest a debug version please? I'm new to ios so don't have a good set of tools setup for everything yet.

Eventually it will be a query, but this first test just involves loading an xml file hosted on a domain.

Good news at least to hear it can be done! Worth persevering then.

Here is the snippet of code for the xml. Once the xml is received it goes into a loop to extract some data and pops the second result into a text field. I tested the code online before sticking it into a new blank ios document. On the iphone, the text just doesn't appear in the text field. Doesn't crash or spaz out or anything.

Thanks

xml.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2011 Jul 21, 2011

You can use the IOErrorEvent.IO_ERROR listener and trace for debugging to see if your xml is being received.

example...

var pageData:XML;

private function getInfo():void {

var url:String = "urlTo.xml";

var myXMLLoader:URLLoader = new URLLoader();

myXMLLoader.addEventListener(Event.COMPLETE, onLoaded, false, 0, true);

myXMLLoader.addEventListener(IOErrorEvent.IO_ERROR, errorXML, false, 0, true);

myXMLLoader.load(new URLRequest(url));

}

private function onLoaded(e:Event):void {

pageData = new XML(e.target.data);

pageData.ignoreWhitespace = true;

//for testing in Flash

trace("Data received: "+pageData);

//for testing to device

// example: textfieldOnStage.htmlText = pageData;

}

//handle xml load error

private function errorXML(e:Event):void {

trace("XML Error:"+ e);

// example: textfieldOnStage.htmlText = pageData;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 21, 2011 Jul 21, 2011
LATEST

Is your example based on this?

http://actionscriptexamples.com/2008/12/05/dynamically-loading-xml-files-in-actionscript-30/


I think you should add the code into a method. For example, use the creationCompleteEvent of the view to call the urlLoader.load method. May be iOS doesnt execute the code that is not in functions...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines