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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:42:25+00:00 2026-05-21T22:42:25+00:00

thanks for reading. I am trying to write a little parser. What I am

  • 0

thanks for reading. I am trying to write a little parser. What I am trying to do is the following. The database contains 3 tables. One with Persons (Name, LastName, Age), one with TextTemplates (“This document belongs to .”) and one with TemplateElements (for example , …). So the user is able to choose a TextTemplate, edit it and add more TemplateElements. As he presses a button the system should generate PDF documents by replacing the TemplateElements with the corresponding properties of the persons out of the Persons table. The problem is to get the persons property that matches the TemplateElement. Of course I could write some:

foreach(element...){    
    if(element.Equals("<Name>"))  
      text.Replace("<Name>", Person.Name);  
    if(element.Equals("<LastName>"))  
      text.Replace("<LastName>", Person.LastName);  
}  

but I want to keep this as dynamic as possible. Properties and TemplateElements could change in the future. So the best solution would be to somehow get the corresponding property according to the actual element.

Would be very nice if one of you guys has a solution for this.

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-21T22:42:26+00:00Added an answer on May 21, 2026 at 10:42 pm

    Have a look at these blog posts where some implementations of ‘named formatters’ are discussed:

    • http://haacked.com/archive/2009/01/04/fun-with-named-formats-string-parsing-and-edge-cases.aspx
    • http://haacked.com/archive/2009/01/14/named-formats-redux.aspx

    Essentially, the idea is that you define an extension method on string that allows you to format a string based on a syntax like {PropertyName}

    Example:

    Person person = GetPerson();
    string text = "Hello, {Name} {LastName}";
    var evaluated = text.FormatWith(person);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for reading. I'm a bit new to jQuery, and am trying to make
Thanks for reading this. I am dynamically generating some data which includes a select
Thanks for reading this. I have markup similar to what is below. Using the
Thanks for reading this I thought I could use find(), but couldn't make it
Thanks for reading this. I would have thought it would be as simple as
I'm reading about Rails fixtures in this guide (thanks, trevorturk). It appears you define
I have been trying to make this to be a little jQuery plugin that
I'm trying to get more into LINQ-to-XML, so I've made myself a neat little
I am trying to write a simple input field validation plugin at the moment
Thanks to a Q&A on stackoverflow. I just found out how to determine the

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.