I want to form a string as <repeat><daily dayFrequency="10" /></repeat>
Wherein the value in "" comes from a textboxe.g in above string 10. I formed the string in C# as
@"<repeat><daily dayFrequency=""+ txt_daily.Text + "" /></repeat>" but i get the output as
<repeat><daily dayFrequency="+ txt_daily.Text+ " /></repeat>. How to form a string which includes the input from a textbox and also double quotes to be included in that string.
To insert the value of one string inside another you could consider
string.Format:This is more readable than string concatenation.
However I would strongly advise against building the XML string yourself. With your code if the user enters text containing a
<symbol it will result in invalid XML.Create the XML using an XML library.
Related