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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:07:55+00:00 2026-06-13T09:07:55+00:00

Can I somehow use a text file with contents like this: <comment> This is

  • 0

Can I somehow use a text file with contents like this:

<comment> This is something like an XML file.
<action var="myInteger"> +50
<condition> stringVar == "sometext" <action var="boolVar"> = true

.. parse it and make my app perform some actions?

The idea is to make a user-friendly (example doesn’t count) pseudocode that can change app’s variables and run methods. Problem is I don’t know how to change variables by their names.

Making a separate case for each variable name (explicitly supporting them) would be rather crazy:

switch(varName)
{
    case "var1": {/* things */ break;}
    case "var2": {/* things */ break;}
    /* ... */
    case "var9999": {/* things */ break;}
}

Edit: I think I asked the wrong question originally. (And it was Is there an easy way to work with application’s variables by executing code from text file?)

  • 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-06-13T09:07:56+00:00Added an answer on June 13, 2026 at 9:07 am

    In answer to your question: yes.

    Now that you’ve edited your question…

    You’ll want to parse the XML, preferably using the libraries that ship with .NET. Then you walk the XML tree, executing each node that has some action associated with it.

    You probably don’t want to expose your app’s variables directly. Instead, you should define some execution state that can be manipulated by the XML file. You could have, for example, a dictionary of variables and their values. Then when you get an <action> tag, you look at the var attribute, look up the variable in the dictionary, then change the value to be whatever the contents of the tag specify.

    This is not a simple task. It’s not necessarily hard to write a language interpreter (which is what you are doing, essentially). But it can be difficult to design your language so that it makes sense. You’ll also find that, if you have embedded expressions (which you appear to), then you’ll need an expression parser. Again, these are “easy” to construct, but for someone without experience, you’ll need to do some research first. You could easily end up constructing something that’s very complicated, slow and broken if you don’t know about real world parsing techniques.

    For expression parsing, look into LL(1) parsers, specifically recursive descent, which is the easiest to understand and implement.

    For evaluating the XML input, you’ll need a recursive algorithm that walks the tree. This will be similar to your recursive descent parser. In fact, the two are pretty much the same except for the details.

    Once you’ve gotten something going, you should ask an actual question about a particular problem, instead of asking one so broad.

    Another edit: use a dictionary for your variables.

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

Sidebar

Related Questions

I've got an XML file which looks somehow like this: <?xml version='1.0' encoding='UTF-8'?> <?xml-stylesheet
This is something I know can be done somehow , because I've done it
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
I've been working all day and I somehow can't get this probably easy task
I would like to avoid the if statement below. Can I somehow copy the
This is the preg_match i am trying to use to find specific text in
I am building an multiple file upload form that user can use to upload
Whenever I use a character set in addition to latin in a text file
For a small python script I would like to use a temporary file with
Can I somehow disable ListView items navigation through keyboard (arrow keys), and leave navigation

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.