2

I have a string that has HTML formatted content.

Now I want to convert that string to HTML, May I use HtmlElementCollection

Is it possible? If yes, then how?

Kindly explain. Thanks!

3
  • 2
    a string that has HTML formatted content is an html Commented Sep 10, 2012 at 12:59
  • But how i can use it as html? for example my string have <tr><td></td></tr> etc... How I can use HtmlElementCollection on it? Commented Sep 10, 2012 at 13:09
  • I don't think you can get from a string to an HtmlElementCollection. An instance of the HtmlElementCollection can only be created through the HtmlDocument, which can only be set from the Document property of the WebBrower control (see msdn.microsoft.com/en-us/library/… for additional information about this. I think what you want to use is the HtmlAgilityPack (see Dan Lister's answer below) Commented Sep 10, 2012 at 13:25

4 Answers 4

2

Take a look at the HtmlAgilityPack. More information can be found on the answers of other similar questions.

Sign up to request clarification or add additional context in comments.

1 Comment

HtmlAgilityPack has moved to html-agility-pack.net/?z=codeplex
1

A string will be handled as HTML when you push this string into an environment that will render the content as HTML.

When you push the content of the string to an environment that doesn't handle HTML or you explicitly say that you don't want it to render as HTML. It will be rendered as plain text.

Comments

1

If someone still locking for this

For that just type code below in the place you what to show the HTML

@((MarkupString)htmlString)

//htmlString =>string that has HTML formatted content

//tested with blazor server last ver of dotnet(now 6.0)

Comments

0

Use HTMLAGILITYPACK and use the following:

var st1 = stringdata; // your html formatted string
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(st1); // this is now html doc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.