Clay Nichols
Clay Nichols

Reputation: 12159

Is there a simple way to create a tag pair (<TagName> value</TagName>) in ASP.net

Is there a built in function (I know I can easily create one) to create simple tags:

MakeTag("Tag","myvalue") would generate: <Tag>myvalue</Tag>

I'd rather something simpler than an XML class and all I need is just a tag created like this.

Also, any suggestions on a parser for the same?

Upvotes: 2

Views: 68

Answers (2)

Kevin Stricker
Kevin Stricker

Reputation: 17388

There is also the TagBuilder class in ASP.NET MVC.

I would use LINQ for simple parsing:

http://www.switchonthecode.com/tutorials/introduction-to-linq-simple-xml-parsing

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351758

Without rolling your own implementation, HtmlGenericControl is about as close as you are going to get:

var control = new HtmlGenericControl("Tag") { InnerText = "myvalue" };

Upvotes: 7

Related Questions