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 trying to write a query to list the names of
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
I am trying to write this method, which keeps reading from the user, until
Thanks for reading this. I'm trying to do this lab from programarcadegames.com where you
thanks for reading this question. Basically I am trying to do a code that
I'm trying to write a plugin for trac but I'm missing sthg. after reading
I'm trying to write some Thread Management utility, and reading up on ThreadMXBean. http://download.oracle.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html#dumpAllThreads(boolean,
I Im trying to read from one text file and write to another one.
i am trying to write a java programm that is reading informations out of
Thanks for reading this. I have no idea why this is throwing a NullReferenceException

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.