Reputation: 611
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=\"<strong>Testing</strong>\"/>
How can i "convert" from html format to xml attribute format?
Upvotes: 1
Views: 413
Reputation: 1157
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.
Upvotes: 1