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

  • Home
  • SEARCH
  • 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 3323390
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:17:49+00:00 2026-05-17T23:17:49+00:00

I’am currently trying to create and application (In c#) that parse a XML file

  • 0

I’am currently trying to create and application (In c#) that parse a XML file and from that change the Text depending on the elements and tags inside the text.

Example:

 <conversation>
   <message from=Bob>
       <typewriter dif=0.5>
           <Text>               
               Bob: Hello <replace>Country<with>World</with></replace>`
           </Text>
      </typewriter>
   <message>
</conversation>

The output would look like this:

It starts writing “Bob: Hello Country” like a old typewriter (letter for letter) and when “Country” is written it will remove that word and start to write World instead. So the final output would be “Bob: Hello World”

So here are my questions:
After parsing the XML file, what is a good approach for storing the data so the program knows what elements contains what elements? (eg. Message contains typewriter)

To get the program to recognize script tags inside of the Text element. How do i do that? and how get it to work like the example?

I’am not asking for completed code here, just some pointers in the right direction. I’am still a beginner at programming so i want to learn.

I didn’t know what to search for so if something like this is already posted then i’am sorry.

  • 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-17T23:17:50+00:00Added an answer on May 17, 2026 at 11:17 pm

    For the most part, you can represent your data the way it’s represented in the XML:

    public class Conversation 
    {
        public IEnumerable<Message> Messages {get;set;}
    }
    
    public class Message
    {
        public string From {get;set;}
        public IEnumerable<TypeWriter> TypeWriters {get;set;}
    }
    

    … etc. But if you XML is going to allow different node types in any order (e.g. typewriters and computers interchangebly), you’ll need to tweak this.

    When it comes to your Text node, the literal text and the other nodes should each be considered to be a kind of action.

    public class TypewriterText
    {
        public IEnumerable<ITypewriterTextAction> TextActions {get;set;}
    }
    
    public enum TypeWriterTextActionType
    {
        Plain,
        Replace
    }
    
    public interface ITypewriterTextAction
    {
        TypeWriterTextActionType ActionType {get;}
    }
    
    public class PlainTypeWriterTextAction : ITypewriterTextAction
    {
        public TypeWriterTextActionType ActionType 
        {
            get {return TypeWriterTextActionType.Plain;
        }
        public string TextToWrite {get;set;}
    }
    
    public class ReplaceTypeWriterTextAction : ITypewriterTextAction
    {
        public TypeWriterTextActionType ActionType 
        {
            get {return TypeWriterTextActionType.Replace;
        }
        public string OriginalText {get;set;}
        public string ReplacementText {get;set;}
    }
    

    Use a technology like LINQ to XML to parse the XML into these objects, then write methods that can take these objects and perform the appropriate actions. For example, you’ll want one class that knows how to do the Plain animation and another that can do the Replace animation, and you can use a switch statement on each action’s Type property to determine which animation class to use.

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

Sidebar

Related Questions

No related questions found

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.