www.webdeveloper.com
Results 1 to 3 of 3

Thread: How do I manipulate information pulled from an XML file?

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    7

    How do I manipulate information pulled from an XML file?

    Good day folks,

    I currently have a bit of a problem with some code I've been working on. I'm pulling information from an xml file to populate a table, but I would like to change the information I have to a string so that I can manipulate it, however I seem to be banging my head against a wall. The code in question is as follows:

    Code:
    var xx=x[i].getElementsByTagName("start");
    var startDate = xx.toString();
    
    var xx=x[i].getElementsByTagName("end");
    var endDate = xx.toString();
    My reason for doing this is to compare the dates which are currently formatted as '21 Jun' and '23 Jun' as an example. The idea is to split the string into the day and month and run a comparison to see if both days are in the same month, and if so then display them as '21/23 Jun' in a table, or as just '21 Jun' if the start and end date are the same, and '21 Jun/03 Jul' if in seperate months.

    The problem lies in that when it tries to do the 'toString()' function I get the error 'Oject doesn't support this property or method'. Can anyone suggest another way of manipulating the xml information to get the end result I'm after please?

    Thanks for reading!

  2. #2
    Join Date
    Jan 2013
    Posts
    7

    How do I manipulate information pulled from an XML file?

    Good day folks,

    I currently have a bit of a problem with some code I've been working on. I'm pulling information from an xml file to populate a table, but I would like to change the information I have to a string so that I can manipulate it, however I seem to be banging my head against a wall. The code in question is as follows:

    Code:
    var xx=x[i].getElementsByTagName("start");
    var startDate = xx.toString();
    
    var xx=x[i].getElementsByTagName("end");
    var endDate = xx.toString();
    My reason for doing this is to compare the dates which are currently formatted as '21 Jun' and '23 Jun' as an example. The idea is to split the string into the day and month and run a comparison to see if both days are in the same month, and if so then display them as '21/23 Jun' in a table, or as just '21 Jun' if the start and end date are the same, and '21 Jun/03 Jul' if in seperate months.

    The problem lies in that when it tries to do the 'toString()' function I get the error 'Oject doesn't support this property or method'. Can anyone suggest another way of manipulating the xml information to get the end result I'm after please?

    Thanks for reading!

  3. #3
    Join Date
    Jan 2013
    Posts
    7
    I figured it out! Basically I should have done the following:

    Code:
    var startDate = xx[0].firstChild.nodeValue.toString();
    Instead of:

    Code:
    var startDate = xx.toString();

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles