So it has been a while since I have written anything, but the issue I just over came was enough to write home about.
My task was to parse some Xml into an object. We all love using the new ways of doing things. I chose to use Linq to Xml. Now I have been using this method for some time now, making life parsing Xml quick and easy.
The problem that I came across was if you lack the control of what that Xml will look like and it is not properly Html Encoded. Linq to Xml does not include the InnerXml property that was once available on XmlElement.
After looking through every available method and property available on the XElement, I thought my life was over and was going to be forced to hack out a solution. The latter is still somewhat true, but the hack has been nicely implemented using an extension method called InnerText.
Below is the code used to generate the InnerText solution, this being the fastest of other solutions such as using a StringBuilder
Thursday, March 4, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment