If you wish to create an XML file and then parse it to use the containing information for some other logic you should keep in mind a small, but annoying “feature”.
Error :
-> org.xml.sax.SAXParseException: Content is not allowed in prolog.
Why:
-> Java known bug:
A Utf-8 stream can optionally beign with a byte order mark (see, for example http://www.unicode.org.unicode/faq/utf_bom.html). This is the character FEFF, which is represented as EF BB BF in utf-8. Java’s utf-8 encoding does not recognize this character as a BOM, though; the result of reading such a stream is a set of characters beginning with FEFF.
-> So, when the XML is generated, before the tag “<?xml…” there will be 3(or more?) hexadecimal characters that will make the parsing logic fail with honors. It looks something like this, although the characters I am using to demonstrate are not the exact ones: “Þ?u<?…”. This is not a valid XML Syntax(having other chars before the ‘<‘) and it will, of course fail when you want to parse it.
One Solution:
– read the XML and convert it into one string(ex. String temp), extract those characters before the “<?” and then create and array of strings resulting from spliting the temp variable. Walking through this array, append each string to a StringBuffer and then you are free to carry on with your logic. It can look something like this:
... String temp = ""; readBuffer.append("<?"); String[] xmlData = temp.split("\n"); for (int i = 0; i < xmlData.length; i++) { readBuffer.append(xmlData[i]); } ... |
Other solutions can be found here, at this Sun Forum page .
If you have a more elegant solution for this I would be glad to know, so feel free to leave a comment with it.
Enjoy 🙂
Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.