A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Render ASP as XML doc?

  1. #1
    Junior Member
    Join Date
    Dec 2001
    Posts
    25

    Render ASP as XML doc?

    I'm pretty new to XML. I have an ASP page that draws data from an Access database. I hav formatted the ASP in XML format.

    Just wondering if there is a way to load the ASP page into Flash and have it render the data as XML?

    I need to keep it as an ASP file so it works correctly on the server.


    Thanks in advance.
    RA

  2. #2
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Flash can read the XML, but it cannot 'render' the XML. You will have to write your own routine on how you want to display the data.

    In which way do you want to display you XML data?

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  3. #3
    Junior Member
    Join Date
    Dec 2001
    Posts
    25
    I have found an XML menu system that works fine. It came with a sample XML file.

    I wanted to recreate the XML file, but use data that is in my Access DB.

    I guess I really just wnted to know if there is a way for Flash to load an ASP file, but have the data treated as XML data.

  4. #4
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    As long as your ASP creates XML similar to the XML file used by the menu component you should be fine. Flash doesn't do any checking of the file extension when reading in XML files.
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  5. #5
    Junior Member
    Join Date
    Dec 2001
    Posts
    25
    I'll post the code. Any idea why this isn't working with the ASP file? In the second frame, if I change the name of the file to the .ASP extension, it doesn't load up. If I use the .xml file, it doesn't work.

    In the first frame:



    Object.version = getVersion().split(',');
    Object.majorVersion = int(substring(Object.version[0],Object.version[0].length, 1));
    Object.minorVersion = int(Object.version[2]);

    if(Object.majorVersion == 5){
    XML.prototype.checkEmpty = function(text){
    var max = text.length;
    var empty = true;
    for(var i=0;i<max;++i){
    if(ord(substring(text, i+i, 1))>32){
    empty = false;
    break;
    }
    }
    return empty;
    }
    XML.prototype.parseXML = function(str){
    this.firstChild.removeNode();
    var treePtr = this;
    var tags = new Array();
    var textNode = null;
    if(Object.minorVersion == 30){
    this.status = ASnative(300, 0)(str, tags);
    }else{
    this.status = ASnative(300, 0)(str, tags, false);
    }
    if (this.status == 0){
    var curr;
    var i=0;
    var max = tags.length;
    if(this.ignoreWhite){
    while(i<max){
    curr = tags[i];
    if(curr.type == 1){
    if(curr.value == "/"+treePtr.nodeName){
    treePtr = treePtr.parentNode;
    }else{
    treePtr.appendChild(this.createElement(curr.value) );
    treePtr = treePtr.lastChild;
    treePtr.attributes = curr.attrs;
    if(curr.empty){
    treePtr = treePtr.parentNode;
    }
    }
    }else{
    if(curr.type == 3){
    if(!this.checkEmpty(curr.value)){
    treePtr.appendChild(this.createTextNode(curr.value ));
    }
    }else{
    if(curr.type == 6){
    treePtr.appendChild(this.createTextNode(curr.value ));
    }else{
    if(curr.type == 4){
    this.xmlDecl = curr.value;
    }else{
    this.docTypeDecl = curr.value;
    }
    }
    }
    }
    ++i;
    }
    }else{
    while(i<max){
    curr = tags[i];
    if(curr.type == 1){
    if(curr.value == "/"+treePtr.nodeName){
    treePtr = treePtr.parentNode;
    }else{
    treePtr.appendChild(this.createElement(curr.value) );
    treePtr = treePtr.lastChild;
    treePtr.attributes = curr.attrs;
    if (curr.empty){
    treePtr = treePtr.parentNode;
    }
    }
    }else{
    if(curr.type == 3 || curr.type == 6){
    treePtr.appendChild(this.createTextNode(curr.value ));
    }else{
    if(curr.type == 4){
    this.xmlDecl = curr.value;
    }else{
    this.docTypeDecl = curr.value;
    }
    }
    }
    ++i;
    }
    }
    }
    }
    }

    In the second frame:


    stop();

    // ||||||||||||||||||||||||||||||||||||||||||||||||||
    // || Convert XML to Object Structure ------------ ||
    // ||||||||||||||||||||||||||||||||||||||||||||||||||

    var XMLfile = 'xmlmenu2.asp'; // the xml file to parse
    importXML = new XML();
    importXML.varTarget = this; // location to tranfer data
    importXML.ignoreWhite = true; // remove whitespace from the xml document

    importXML.onLoad = function(success){
    if(success){
    // pointer to data tranfer location
    var vt = this.varTarget;
    // pointer to root node
    var root = this.firstChild;

    // --------------------------------------------------

    vt.menuObj = new Object();

    var i, j, k, m;
    for(i = root.lastChild, j = 1; i != null; i = i.previousSibling, j++){
    vt.menuObj['item'+j] = new Object();
    vt.menuObj['item'+j].name = i.attributes.name;
    vt.menuObj['item'+j].arg = (typeof(i.attributes.arg) == 'undefined') ? null : i.attributes.arg ;
    vt.menuObj['item'+j].sub = false;
    if(i.hasChildNodes()){
    vt.menuObj['item'+j].sub = true;
    for(k = i.lastChild, m = 1; k != null; k = k.previousSibling, m++){
    vt.menuObj['item'+j]['sub'+m] = new Object();
    vt.menuObj['item'+j]['sub'+m].name = k.attributes.name;
    vt.menuObj['item'+j]['sub'+m].arg = k.attributes.arg;
    }
    }
    }
    vt.play(); // data conversion complete

    // --------------------------------------------------

    }else{
    trace('ERROR PARSING XML');
    }
    }
    importXML.load(XMLfile);

    // ||||||||||||||||||||||||||||||||||||||||||||||||||





  6. #6
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    I assume that your .xml file does work. Test your ASP file with IE, it will recognise the XML and create a colorised XML tree view.

    This way you can tell whether it is an ASP problem or a XML problem. Does your ASP file, simply never load, or does it put a message in the output window of:

    ERROR PARSING XML


    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

  7. #7
    Junior Member
    Join Date
    Dec 2001
    Posts
    25
    Weird...I just tried loading it again and it worked fine. I must've been doing something wrong somewhere.

    Thanks for your help!

  8. #8
    Senior Member tupps's Avatar
    Join Date
    Jan 2001
    Location
    Melbourne
    Posts
    2,035
    Your browser/server might have a cache of the bad page. When you tried again it downloaded new data. (Do you have your browser set to cache everything once person session?)

    Thanks

    Luke
    Flash-XML FAQ
    http://www.tupps.com/flash/faq/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center