Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 339297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:30:36+00:00 2026-05-12T10:30:36+00:00

if I have an XML object like this: <a> <u date=2009-04-10 value=543/> <u date=2009-04-11

  • 0

if I have an XML object like this:

    <a>
    <u date="2009-04-10" value="543"/>
    <u date="2009-04-11" value="234"/>
    <u date="2009-04-13" value="321"/>
    <u date="2009-04-14" value="66"/>
    <u date="2009-04-16" value="234"/>

    <t date="2009-04-01" value="43"/>
    <t date="2009-04-02" value="67"/>
    <t date="2009-04-03" value="432"/>
    <t date="2009-04-08" value="123"/>
    <t date="2009-04-09" value="65"/>

    <l date="2009-04-01" value="12"/>
    <l date="2009-04-02" value="76"/>
    <l date="2009-04-03" value="123"/>
    <l date="2009-04-04" value="6543"/>
    <l date="2009-04-05" value="123"/>
    <l date="2009-04-06" value="65"/>
    <l date="2009-04-15" value="234"/>
    <l date="2009-04-16" value="65"/>
</a>

There is 3 XMLLists in this XML object. If you notice, the dates have gaps in them. Is there a way to add the missing dates to each XMLList? With a value of 0.

Also I do not want to add any dates before or after the first and last node in each XMLList…i just want to fill in the missing dates between each node.

How can I do that?

Thanks!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:30:36+00:00Added an answer on May 12, 2026 at 10:30 am

    It isn’t that easy unfortunately. There is not timedelta class (like Python) in Actionscript. This makes finding the distance between dates a bit of a pain. It isn’t too bad if you can guarantee that the dates will always be within the same month (e.g. 1-31 within a given month). Then you can use something like:

    package
    {
    import flash.display.Sprite;
    
    public class TestXML extends Sprite
    {
    public function TestXML()
    {
        var xml:XML = 
        <a>
            <u date="2009-04-10" value="543"/>
            <u date="2009-04-11" value="234"/>
            <u date="2009-04-13" value="321"/>
            <u date="2009-04-14" value="66"/>
            <u date="2009-04-16" value="234"/>
    
            <t date="2009-04-01" value="43"/>
            <t date="2009-04-02" value="67"/>
            <t date="2009-04-03" value="432"/>
            <t date="2009-04-08" value="123"/>
            <t date="2009-04-09" value="65"/>
    
            <l date="2009-04-01" value="12"/>
            <l date="2009-04-02" value="76"/>
            <l date="2009-04-03" value="123"/>
            <l date="2009-04-04" value="6543"/>
            <l date="2009-04-05" value="123"/>
            <l date="2009-04-06" value="65"/>
            <l date="2009-04-15" value="234"/>
            <l date="2009-04-16" value="65"/>
        </a>; // / // <-- need this for stack overflow parse bug :(
    
        fillBlanks(xml, xml..u);
        fillBlanks(xml, xml..t);
        fillBlanks(xml, xml..l);
    }
    
    private function fillBlanks(rootNode:XML, list:XMLList):void
    {   
        var dateString:String;
        var matches:Array;
        var currentDate:Date;
        var lastDate:Date;
        for each(var node:XML in list)
        {
            dateString = node.@date.toString();
            matches = dateString.match(/(\d+)\-(\d+)\-(\d+)/);
            currentDate = new Date(matches[1], matches[2], matches[3]);
    
            while(lastDate && (currentDate.date - lastDate.date) != 1)
            {
                rootNode.insertChildBefore(node, new XML(
                    "<" + node.name() + " date=\"" + 
                    lastDate.fullYear + 
                    "-" + 
                    lastDate.month + 
                    "-" + 
                    (lastDate.date + 1) + 
                    "\" value=\"0\" />"));
    
                lastDate = new Date(lastDate.fullYear, lastDate.month, lastDate.date + 1);
            }
    
            lastDate = currentDate;
        }
    }
    }
    }
    

    This doesn’t do fancy stuff like pad “0” before months or dates that are less than 10. It also will not handle if your ranges cross month barriers. The first is really easy to fix so I leave it to you. The second is not very easy at all (especially if the dates cross year boundaries as well) and again I’ll leave it to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML object being returned, and inside is a date and time
I have a datagrid with an XML object as dataprovider. There are 2 columns
I have a basic XML object that I'm working with. I can't figure out
I have an XML document that I generate from an Entity Framework object. The
I have an XML file that I'm trying to serialize into an object. Some
I have an xml string below that I've turned into an object using $content
I have parsed XML file into objects, in which each object has a 1:1
I have a listView, populated with an ArrayList of object (xml parsing) and an
I'm working with SOAP using the javax.xml.soap package. I have a javax.xml.soap.SOAPMessage object that
I have a xml and I want to sort it by date.my code till

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.