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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:58:38+00:00 2026-06-17T12:58:38+00:00

I have xml file with specific steps and actions that have to be performed

  • 0

I have xml file with specific steps and actions that have to be performed on html controls:

<Item control="Dropdown" action="Click" value=""/>
<Item control="Button" action="GetText" value=""/>
<Item control="Input" action="WriteText" value="Sample Text"/>

There is a lot of controls that I will use and each control has several methods like Click, GetText, Exsists..

Currently I use switches to deal with it, but I heard that this is not a good practice. I have one switch to select specific control and also each control has switch to call specific method.

switch (control)
            {
                case "button":
                    return new Button;
                case "table":
                    return new Table;
                (...)
            }

(...)


        switch (action)
        {
            case "click":
                this.Click();
                return true;
            case "gettext":
                this.GetText();
                return true;
            default:
                return false;
        }

I don’t have much experience with coding so I’m not sure whether it is good way to deal with this problem. Could you give me some suggestions how to do it better? Maybe there are some coding patterns which could be helpful here?

  • 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-17T12:58:39+00:00Added an answer on June 17, 2026 at 12:58 pm

    you could create a class for each type of control you have

    namespace SomeNamespace {
        class Button {
        }
        public void Click(){
        }
    }
    

    and then when you read the XML

    //assemblyName is the full name of the assembly holding your control classes
    var type = System.GetType(assemblyName, "SomeNamespace." + control);
    var control = Activator.CreateInstance(type); //requires a default constructor
    type.GetMethod(methodName).Invoke(control); //methodName could be click
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that I need to find the item of specific
I have a compiled .NET assembly with a specific resource file embedded (named 'Script.xml').
What is the easiest way to convert xml to html? I have xml file
I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>
I have an XML file that reads like this <abc> <ab>value</ab> <aa>time</aa> <ac>money</ac> </abc>
I have an XML file that I'm trying to read from here , and
I have an XML file that is well formed and valid (matched with an
I have a large XML file (converted to JSON) that consists of multiple repeating
I have an XML file in a string in this format: <item> <name>xxx</name> <id>yyy</id>
i have the following question: I have a XML file with some elements that

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.