Thursday, April 14, 2011

ASP.NET SiteMap control invalid XHTML -title contains &

Hi all,

I'm using the .SiteMap file and Sitemap control to create a sitemap on a page. The title of the page in the Web.sitemap is: "Out & About".

When the page renders, the ampersand is shown as an & (Out & About) in the source, this obviously then causes validation errors.

Any ideas how I can force good ol' .net sitemap to encode the ampersand as I entered it into the title.

As usual, thanks for any help. peteski

From stackoverflow
  • Use HttpUtility.HtmlEncode to encode your text first, this will emit the appropriate entities (in this case "&amps;").

    peteski22 : I don't see how I can do this as the .SiteMap file is XML.
    Richard : You an manually add an extra level of encoding in your file: "&s;amps;"
    Richard Collette : This should be marked as a solution since it does work.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.