Skip to main content
Participant
May 21, 2007
Question

problem with loading xml

  • May 21, 2007
  • 2 replies
  • 466 views
i tried to load xml
but nothing happend
application.onConnect = function(newClient, name)
{
application.acceptConnection(newClient);
var flooring = new XML();
flooring.ignoreWhite = true;

flooring.onLoad = function(success) {
trace(success);
};

flooring.load("Gallery.xml");
}

what is wrong? do i need to change port?
    This topic has been closed for replies.

    2 replies

    May 21, 2007
    I've never had success loading a local XML file in FMS... always get the same error as you.

    My solution is to use the File() object to read the XML file into a string, and then use xml.parseXML() to create an XML object from the string.
    dfm_
    Known Participant
    May 21, 2007
    var flooring:XML = new XML();
    flooring.ignoreWhite = true;
    flooring.onLoad = function(success:Boolean) {
    if (success) {
    trace(flooring);
    } else {
    trace("could not find XML");
    }
    };
    flooring.load("Gallery.xml");

    if this could not work, then is application.onConnect
    July 18, 2007
    I'm also having problem loading xml in the fms2.
    i did one function for testing porpuse :
    application.getDBHello= function(){
    var login_str = "<login username=\"servidor\"password=\"servpass\" />";
    var my_xml = new XML(login_str);
    this.myLoginReply_xml = new XML();
    this.myLoginReply_xml.ignoreWhite = true;
    this.myLoginReply_xml.onLoad= function(success) {
    trace("Executing Onload: "+success);
    trace(this.myLoginReply_xml);
    if (success) {
    trace("firstnode ="+this.firstChild.nodeName)

    } else {
    trace("something went wrong!!!! =P")
    }
    };
    this.myLoginReply_xml.onData=function (mdata){
    trace("Executing on DATA "+mdata);
    trace("xml state "+this.loaded)
    }
    my_xml.sendAndLoad(this._dataServer,this.myLoginReply_xml);
    }

    and o call it from inside the application.onConnect

    if you try this you will see that the onData is fired but not the onLoad.

    In fact if you get to the documentation of "Server-Side ActionScript Language Reference" for fms2 you'll find the following information:
    "When the load() method is executed, the XML object property loaded is set to false.
    When the XML data finishes downloading, the loaded property is set to true, and the
    onLoad event handler is invoked. The XML data is not parsed until it is completely
    downloaded. If the XML object previously contained any XML trees, they are discarded.
    You can define a custom function that executes when the onLoad event handler of the XML
    object is invoked."

    I tested the xml.loaded var in the onData and returned false. It should be true so that onLoad is executed.
    Do you think this is a bug?