A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: covert XML value to Integer type!

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Location
    London
    Posts
    240

    covert XML value to Integer type!

    Basically I'm reading in a XML file with



    PHP Code:
    "<a_storynum>13</a_storynum>" 
    Which it is retrieving the correct values however beacuse a_storynum this will later be used for array access it needs to be a int which Ive tried doing like so


    Code:
    storynum = Number(a_storynum);
    however the answer is always 0 - is there a way I can parse it or something?

    Code:
    
    // This is the retrieving the XML
    
    function getContent() {
    	//how_text = "Match the Latin names to the correct rooms on this plan of a Roman house. Drag a label from the list on to the room it fits. If you wish to change your mind, click on the label again to deselect it. When you have used all the labels, click on SUBMIT to find out how well you have done.";
    	// Retrieves the contents of the nodes and sets them as variables
    	node_count = 0;
    	var strValue;
    	var ndRoot = content.childNodes[0];
    	do {
    		var nd = ndRoot.childNodes[node_count];
    		if (nd.childNodes.length>1) {
    			strValue = nd.toString();
    		} else {
    			//traced += "\nhere in else="+nd.firstChild.toString();
    			strValue = nd.firstChild.toString();
    		}
    		set(nd.nodeName, strValue);
    		traced += "\n"+nd.nodeName+"="+strValue;
    		node_count += 1;
    	} while (node_count < ndRoot.childNodes.length);
    }
    content = new XML();
    content.onLoad = getContent;
    content.ignoreWhite = true;
    content.mc = this;
    content.load(_level0.xml_url);
    
    // goes to the "go" position
    gotoAndStop("go_1");
    Last edited by VAYKENT; 06-04-2003 at 12:56 AM.
    Alison

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112
    I celaned up your post a bit, so we could see everything... do you have a 'complete' snippet of the XML you're using?

    ... and this doesn't make much sense...
    Code:
    		if (nd.childNodes.length > 1) {
    			strValue = nd.toString();
    		} else {
    			//traced += "\nhere in else="+nd.firstChild.toString();
    			strValue = nd.firstChild.toString();
    		}
    Richard Lyman
    rich at lithinos.com
    www.lithinos.com

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