Zeeshan Hirani

Senior .net Developer
CheaperThanDirt.com

XElement.ToString returns encoded text

I am sure people who do XML on a day to day basis would not find surprising but I think it was pretty cool to see that when I call  ToString on my XML, I get back my entire XML with whitespace preserved and also all text is encoded for me automatically. I created my XML using .net 2.0 api and saw the same behavior so I guess this was not a new feature but definitely a good default option to encode your text before outputting it to the user. Here is simple example that illustrates this behavior.

image

image

As you can see from the above code, my title and author value have some html tags that gets encoded when i output the content to the console.

Posted: Jul 17 2008, 01:19 AM by zhirani | with no comments
Filed under: ,

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)