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 6927745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:05:43+00:00 2026-05-27T11:05:43+00:00

I need to come up with a program that generates an xml file like

  • 0

I need to come up with a program that generates an xml file like this:

<?xml version="1.0"?>
<xc:XmlCache xmlns:xc="XmlCache" xc:action="Update">
    <xc:XmlCacheArea xc:target="AllSubFields" xc:value="MarketParameters">
        <mp:nickName xmlns:mp="mx.MarketParameters" xc:value="MDS">
            <mp:date xc:value="TODAY">
                <fx:forex xmlns:fx="mx.MarketParameters.Forex">
                    <fxsp:spot xmlns:fxsp="mx.MarketParameters.Forex.Spot">
                        <fxsp:pair type="Fields" value="USD/BRL">
                            <mp:ask xc:type="Field" xc:keyFormat="N">1.890</mp:ask>
                            <mp:bid xc:type="Field" xc:keyFormat="N">1.800</mp:bid>
                        </fxsp:pair>
                    </fxsp:spot>
                </fx:forex>
            </mp:date>
        </mp:nickName>
    </xc:XmlCacheArea>
</xc:XmlCache>

with the values in the nodes mp:ask and mp:bid randomly generated but between two predefined values (1.65 and 1.99).

After the xml is generated in the same directory of the program, the program should run a command in the cmd command line that states:

cachetool.bat -i cacheBody.xml -u REALTIME

where cachetool.bat is an already done bash script that cannot be changed and that is also place in the same directory of the program, and where cacheBody.xml is that previously generated xml.

The trick here is that this should run repeatedly overwriting the xml file with new values each time and then running the command again calling the xml with the new values.

There should be a way to easy interrupt the loop, but besides that, this should run indefinitely.

Note: there isn’t a strict rule to use c or c++, if it isn’t feasible in these languages or if there other ways to do it easily, please feel free to suggest. My initial proposal is in these languages because these are the two that I’m a little used to deal with.

  • 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-27T11:05:44+00:00Added an answer on May 27, 2026 at 11:05 am

    I’m learning how to use javascript for Windows local scripting, so here’s a solution in javascript.

    It looks like you don’t really need to generate the XML dynamically, but rather the XML structure is static and only a couple data fields are dynamic. With that in mind, I approached the problem with search-and-replace using a template file.

    The template file (template.xml) contains xml content with some variables to search and replace. The format variable format is $RANDOM_X_Y$, where X and Y are the lower and upper bounds for the random number. To help the example, I generated the ask and bid prices slightly differently in the template file:

    <?xml version="1.0"?>
    <xc:XmlCache xmlns:xc="XmlCache" xc:action="Update">
        <xc:XmlCacheArea xc:target="AllSubFields" xc:value="MarketParameters">
            <mp:nickName xmlns:mp="mx.MarketParameters" xc:value="MDS">
                <mp:date xc:value="TODAY">
                    <fx:forex xmlns:fx="mx.MarketParameters.Forex">
                        <fxsp:spot xmlns:fxsp="mx.MarketParameters.Forex.Spot">
                            <fxsp:pair type="Fields" value="USD/BRL">
                                <mp:ask xc:type="Field" xc:keyFormat="N">1.$RANDOM_65_99$0</mp:ask>
                                <mp:bid xc:type="Field" xc:keyFormat="N">1.$RANDOM_650_990$</mp:bid>
                            </fxsp:pair>
                        </fxsp:spot>
                    </fx:forex>
                </mp:date>
            </mp:nickName>
        </xc:XmlCacheArea>
    </xc:XmlCache>
    

    The javascript file is called replace.js. All versions of Windows should be able to execute it natively without installing any extra components.

    if( WScript.Arguments.Count() != 2 || WScript.Arguments.Item(0) == WScript.Arguments.Item(1) )
    {
        WScript.Echo("Usage: replace.js <template> <output filename>");
        WScript.Quit();
    }
    
    var template_filename = WScript.Arguments.Item(0);
    var output_filename = WScript.Arguments.Item(1);
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var ForReading = 1;
    var file, file_contents, lower, upper;
    var var_regex = /\$RANDOM_(\d+)_(\d+)\$/g;
    
    if( fso.FileExists(template_filename) )
    {
        file = fso.OpenTextFile(template_filename, ForReading, false);
    
        file_contents = file.ReadAll().replace(var_regex,
                function(str, lower, upper) {
                    return Math.floor(
                        Math.random() * (+upper - +lower + 1)) + +lower;
                });
        file.Close();
    
        file = fso.CreateTextFile(output_filename, true);
        file.Write(file_contents);
        file.Close();
    
    }
    else
    {
        WScript.Echo("Template does not exist: " + template_filename);
    }
    

    Now to run your scripts indefinitely, just create a batch file called run.bat or whatever and have it run the javascript and batch files in a loop. CTRL–C will exit the script.

    @echo off
    echo Starting.  Press CTRL-C to exit.
    :loop
            replace.js template.xml cacheBody.xml
            cachetool.bat -i cacheBody.xml -u REALTIME
    goto loop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing this program that will need to access the registry to pull some
If I know that input to my program will come from a file descriptor
Maybe this sounds a little bit crazy, but I need to come up with
I'm trying to write a program that modifies fractions and I need to make
The algorithm I need to come up with is one that computes all the
Today I decided to come up with a program that would be useful for
Basically I need a program that will sort windows .exe's from the console counterparts.
Ok, I need some help here. I'm attempting to write a program that rolls
So I have this Java program that I use to munch through several terabytes
I need some guidance on how best to run this program. Im trying to

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.