A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: search through my xml

  1. #1
    Senior Member
    Join Date
    Jul 2004
    Location
    outside Philly
    Posts
    154

    search through my xml

    I have a site that is using xml and it is parsed like this

    Code:
    images_xml = new XML();
    //images_xml.ignoreWhite = false;
    images_xml.ignoreWhite = true;
    images_xml.onLoad = function(success) {
        if (!success) {
            trace("Couldnt load XML file");
        } else {
            //parse your XML data
            //trace("MY XML: " + images_xml.firstChild);
            var projNode = images_xml.firstChild.childNodes;
            var projTotal = projNode.length;
    		_root.projTotal = projNode.length;
            trace("MY XML: projNode " + projNode);
            trace("MY XML: projTotal " + projTotal);
            for (i = 0; i < projTotal; i++) {
                //create a new object for each project
                trace("Object Names: " + " imageObject" + i);
                imageObject = _level0["imageObject" + i] = new Object();
                //add all data into an object
                imageObject.id = projNode[i].attributes.id;
                trace("ID: " + imageObject.id);
                imageObject.date = projNode[i].childNodes[0].firstChild.nodeValue;
                trace("Date: " + imageObject.date);
                imageObject.name = projNode[i].childNodes[1].firstChild.nodeValue;
                trace("Name: " + imageObject.name);
    			imageObject.introtext = projNode[i].childNodes[2].firstChild.nodeValue;
                trace("introtext: " + imageObject.introtext);
                imageObject.comment = projNode[i].childNodes[3].firstChild.nodeValue;
                trace("Comment: " + imageObject.comment);
    			imageObject.start = projNode[i].childNodes[4].firstChild.nodeValue;
    			trace("start: " + imageObject.start);
    			imageObject.end = projNode[i].childNodes[5].firstChild.nodeValue;
    			trace("end: " + imageObject.end);
                imageObject.thumb = projNode[i].childNodes[6].firstChild.nodeValue;
                trace("Thumb: " + imageObject.thumb);
                
            } 
        } 
    }; 
    
    images_xml.load("project-c.xml");
    Now the xml is working fine but I am trying to add a code that will search through and show the next scheduled event from inside a movieclip. I think the code should be something like this
    Code:
    for (i = 0; i < _root.projTotal; i++) {
    	tester="_root.imageObject"+i
    	trace(tester+" tester")
    	trace(tester.date+" tester.date")
    	trace(_root.imageObject0.date+" date")
    if(_root.newday==tester.date){
    	trace("worked")
    }
    }
    and that will trace

    _root.imageObject0 tester
    tester.date
    6.18.2009 date
    _root.imageObject1 tester
    tester.date
    6.18.2009 date
    _root.imageObject2 tester
    tester.date
    6.18.2009 date

    So as you can see the variable tester.date doesnt work but when you type out the imageObject0.date it works. Can someone please explain how I can search through the xml date info and determine if it is the same day.

    Thanks I appreciate the help,
    Randy

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    to help us to test your code, please post your xml file (or a usable snippet of it )

  3. #3
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PS .. i notice you are passing a string variable - tester="_root.imageObject"+i

    try passing the string as an object - tester=_root["imageObject"+i];

  4. #4
    Senior Member
    Join Date
    Jul 2004
    Location
    outside Philly
    Posts
    154
    tester=_root["imageObject"+i]; worked
    thanks for your help dog. I really appreciate it.

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