Wednesday, September 22, 2010

How can I take an xml string and display it on my page similiar to how StackOverflow does it with 'insert code'?

Programmer Question

Hi All,



I'm using the DataContractSerializer to convert and object returned from a WCF call to xml. The client would like to see that xml string in a webpage. If I output the string directly to a label, the browser strips out the angle brackets obviously. My question is how can I do something similar to StackOverflow? Are they doing a find & replace to replace angle brackets with their html entities? I see they are doing a code tag inside a pre tag and then making spans with the appropriate class. Is there an existing utility out there I can use to do this instead of writing some kind of parsing routine. I'm sure something free must be out there. If anyone can direct to the right place or some code that can easily accomplish this, I would greatly appreciate it. I apologize if this is more of a meta.stackoverflow question. Thanks for any tips.



Cheers,

~ck in San Diego



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails