Sunday, September 07, 2008

Adding XML to your Posts in the Blogger

Have you ever tried to post some XML to your posts and got only some values of the tags, loosing all of the XML?

So that an XML like:


<dependency>
<groupId>javanettasks</groupId>
<artifactId>httpunit</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>


becomes:


javanettasks
httpunit
1.7
compile


Why is that????

The problem is that the XML is been interpreted as part of the HTML.
To avoid this you can use the following site:

http://www.elliotswan.com/postable/

It will replace the '<' and '>' symbols (among others) to XML entities, that will be shown correctly in the html but won't make your browser think that they are part of the HTML. You paste the xml there, and as a result you will get something like:

& lt;dependency& gt;
& lt;groupId& gt;javanettasks& lt;/groupId& gt;
& lt;artifactId& gt;httpunit& lt;/artifactId& gt;
& lt;version& gt;1.7& lt;/version& gt;
& lt;scope& gt;compile& lt;/scope& gt;
& lt;/dependency& gt;

That then you can paste safely in your post. To get the best formatting, add a </pre></pre> tags before and after the text.

0 comments: