Amit, is there a reason why you can't create the items as Eric shows you? Are the values being passed that require you to create code on the fly? If so, you need to be clear. Even so, you can get the information from the request if that's being passed and then load that information into your document via a script within the portion of the body where the item needs to be. Please provide more information.
If you are doing this to add a level of complexity to your code to make you appear more valuable or knowledgeable, please don't. Complexity is the hallmark of the junior programmer. If you can do it simply, then do it simply. Save complexity for real problems.