1

I'm using C#.
I have the following html text: < strong>Testing< /strong>; (without the space before start tag, end tag).

I'm trying to insert this html text to attribute of my html element as follow:

<MyElement myAttribute=\"&lt;strong&gt;Testing&lt;/strong&gt;\"/>

How can i "convert" from html format to xml attribute format?

1 Answer 1

1

You can simply use https://msdn.microsoft.com/en-us/library/73z22y6h(v=vs.110).aspx

I.e

string encodeValue = HttpUtility.HtmlEncode("<strong>Testing</strong>");

And then you can use encodeValue to insert into your xml attribute.

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

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.