I am creating an XML document with jDom. The result XML file contains & instead of '&'. How can I escape these characters? please throw some light on this..
If you used standard XML software to output the DOM to an XML document, I would expect it to escape that character properly without being asked. That is just normal behaviour. Am I correct that your question is that your output contains something like
<text>This & that</text>
which is malformed XML, and you want it to contain this well-formed example instead?
<text>This & that</text>
If so, let's see the code you are using to output the document.
No, it isn't really a "Java Ranch issue". It's just HTML, which has the same escaping rules as XML. If you know the rules then you should be able to make it display what you want it to display.
Anyway, you seem to be saying that you don't want the correct XML, you actually want malformed XML. Is that right? If so, why?
Yes, I need the data as it is because I want to use this XML for processing data in other application. This is the requirement. The external application is not currently recognizing this escaped data..please note that i am not using this data to represent in the HTML. This is just for transaction purposes.
You could write an XSL transformation to convert your document to malformed XML by using the "disable-output-escaping" attribute of the "xsl:text" element.