S
shapper
Hello,
I am trying to change the following string:
"<span class=\"Error\">Required field</span>"
To:
"<p class=\"Error\"><span>Required field</span></p>"
The initial span tag should be replaced by "p".
The inner text should be wrapped inside a new span tag with no
attributes.
However I am getting the following:
"<span class=\"Error\"><span>Required field</span></span>"
The span tag is not being replaced by "span".
I know my code is probably not the most robust, from a previous post
feedback but since the the string will be always very similar I think
my approach is ok.
My code is as follows:
String html = htmlHelper.ValidationMessage(modelName,
validationMessage, htmlAttributes);
XmlDocument xml = new XmlDocument();
if (!String.IsNullOrEmpty(html)) {
html.Replace("span", "p");
xml.LoadXml(html);
xml.DocumentElement.InnerXml = String.Concat("<span>",
xml.DocumentElement.InnerText, "</span>");
}
return xml.InnerXml;
The code that is not working is html.Replace("span", "p");
My code seems to be ok ...
Any idea why it is not working?
Thanks,
Miguel
I am trying to change the following string:
"<span class=\"Error\">Required field</span>"
To:
"<p class=\"Error\"><span>Required field</span></p>"
The initial span tag should be replaced by "p".
The inner text should be wrapped inside a new span tag with no
attributes.
However I am getting the following:
"<span class=\"Error\"><span>Required field</span></span>"
The span tag is not being replaced by "span".
I know my code is probably not the most robust, from a previous post
feedback but since the the string will be always very similar I think
my approach is ok.
My code is as follows:
String html = htmlHelper.ValidationMessage(modelName,
validationMessage, htmlAttributes);
XmlDocument xml = new XmlDocument();
if (!String.IsNullOrEmpty(html)) {
html.Replace("span", "p");
xml.LoadXml(html);
xml.DocumentElement.InnerXml = String.Concat("<span>",
xml.DocumentElement.InnerText, "</span>");
}
return xml.InnerXml;
The code that is not working is html.Replace("span", "p");
My code seems to be ok ...
Any idea why it is not working?
Thanks,
Miguel