I am trying to ask a question which contains sample XML code but I can't paste sample XML code in the question. How it can be done?
Note that if your XML doesn't get recognized despite the code block, you can add
<!-- language: lang-xml -->
Feature was added in 2011 so I realize it was not available at the time the question and the other answers were placed.
XML is still a language so use the regular code button (its the icon with binary on it) otherwise use http://pastebin.com to post the code and then past the link here.
Not that hard