First of all I want to mention that this is not a duplicate of  because I don't have a given invalid (or not well-formed) XML file but rather a given arbitrary Java String which may or may not contain an invalid XML character. I want to create a DOM Document containing a Text node with the given String, then transform it to a file. When the file is parsed to a DOM Document I want to get a String which is equal to the initial given String. I create the Text node with org.w3c.dom.Document#createTextNode(String data) and I get the String with org.w3c.dom.Node#getTextContent().  As you can see in  there are some invalid characters for Text nodes in a XML file. Actually there are two different types of "invalid" characters for Text nodes. There are predefined entities such as ", &amp;, ', &lt; and &gt; which are automatically escaped by the DOM API with &amp;quot;, &amp;amp;, &amp;apos;, &amp;lt; and &amp;gt; in the resulting file which is undone by the DOM API when the file is parsed. Now the problem is that this is not the case for other invalid characters such as '\u0000' or '\uffff'. An exception occurs when parsing the file because '\u0000' and '\uffff' are invalid characters.  Probably I have to implement a method which escapes those characters in the given String in a unique way before submitting it to the DOM API and undo that later when I get the String back, right? Is there a better way to do this? Did someone implement those or similar methods in the past?  Edit: This question was marked as duplicate of . I have now read all of the answers but none of them solves my problem. All of the answers suggest:   Using a XML library such as the DOM API which I already do and none of those libraries actually replaces invalid characters except ", &amp;, ', &lt;, &gt; and a few more. Replacing all invalid characters by "&amp;#number;" which results in an exception for invalid characters such as "&amp;#0;" when parsing the file. Using a third party library with an XML encode method which do not support illegal characters such as "&amp;#0;" (they are skipped in some libraries). Using a CDATA section which doesn't support invalid characters either.
Very similar to , except for Java.  What is the recommended way of encoding strings for an XML output in Java. The strings might contain characters like "&amp;", "&lt;", etc.
Is it possible to see own 'review queue audits' results? I completed recently a few review audits, some of them I passed, some I failed.  Is there a place I could (easily) find these results? iOS 9.2 double touch fingerprint sensor Using Thunderbird and gmail, sent items appear as unread in "All Mail" I'm using a gmail account in Thunderbird. When I send a message, a new mail notification appears (sound and system try icon), an unread message appears in the gmail All Mail folder, and the account name turns blue.  I have to click on "Sent Mail" or "All Mail" to get rid of the notification. Unsubscribing from "All Mail" is not effective (it still turns the account name blue).  This seems to be popping up elsewhere (), but nobody has posted a helpful answer.  How do I keep Thunderbird from thinking that a sent message is new unread mail in the All Mail folder? How to calculate $\lim \limits_{n \to \infty}(1 +\frac{a}{n})^n$? I know what solution is $e^a$ but I don't know how to calculate this limit:  $$\lim \limits_{n \to \infty}\left(1 + \frac{a}{n}\right)^n=e^a$$  Can someone explain the steps to me? Game resource timers - general implementation I'm interested in understanding how resource generation timers work on many of the mmorts type games out there. I can't wrap my head exactly around how the timers are synched with servers, especially with multiple users. If I need to provide more details, please let me know.  Thanks! What does the complex electric field show? We have a complex electric field. Is there any definition for absolute and imaginary part of a complex electric field? What do they stand for? continuous function: preimage of closure of a set is closure of preimage Someone from Mars is called a Martian. Someone from America is called an American. Someone from Europe is a European. Someone from Hyrule is a Hyrulean.  We are not far from colonizing other planets, let alone Earth's only moon. Obviously you wouldn't call someone from the moon a lunatic right? What if you are on Mars? What would I call a foreigner from Earth? Earthean doesn't sound right. Is there a word that describes a parent whose child has died?   Along the lines of "orphan", "widow", and "widower", is there a single word for a parent who has lost a child (of any age)? You see him for a split second in the final scene with the Final Order and he has kind of a white beard. I can't find any reference online except Nien Nunb from ROJ. How to sort a list of objects based on an attribute of the objects? I'm hoping someone can give me a nudge in the right direction...     Let $F$ be a finite field, and let $f(x)$ be a nonconstant polynomial whose derivative is the zero polynomial.  Prove that $f$ cannot be irreducible over $F$.   I've got that every root of $f$ is a multiple root and that for $F=\mathbb{F}_{p^r}$, the exponent of every term of $f$ is a multiple of $p$. Does the following limit exist? $$\lim_{x \to 0} x\sin\left(\frac{1}{x}\right)$$  If yes, then I have to find it; if no, then I need to give reason why. I couldn’t figure out how to prove this formally, can someone please help me out. I have created a 'control' using jQuery and used jQuery.extend to assist in making it as OO as possible.  During the initialisation of my control I wire up various click events like so  jQuery('#available input',              this.controlDiv).bind('click', this, this.availableCategoryClick);   Notice that I am pasing 'this' as the data argument in the bind method. I do this so that I can get at data attached to the control instance rather from the element that fires the click event.   This works perfectly, however i suspect there is a better way  Having used Prototype in the past, I remember a bind syntax that allowed you to control what the value of 'this' was in the event.  What is the jQuery way? Does Airplane Mode allow GPS location to pass through? This is what I saw when my plane was taxing to the runway at CDG:     Airplane mode was on and all other transmissions (except Location), including WiFi, mobile data, NFC and Bluetooth were off.  Location was not manually turned on by me, after I enabled Airplane Mode. It remained turned on.  What am I missing? Is GPS now so widely accepted on-board planes that Android changed its configuration to let this kind of signal/communication to pass through Airplane mode "block"?  I believe that  isn't a duplicate, because at that time (2016) Location was generally "included" in Airplane mode and was turned off by enabling it. How to add a gif file to my LaTeX file? Related:          I have an image file -- a gif file, which is the graph of a function. How do I add it to a LaTeX file? Will it come out OK in the subsequent pdf file? How can I get apt to use a mirror close to me, or choose a faster mirror? What is the difference between operator "=" and "==" in Bash? Does a finite $[E:K]_s$ imply that $[E_s:K]$ is finite? Let $E/K$ be an algebraic extension of fields and denote by $E_s$ the separable closure of $K$ in $E$, i.e. the set of all elements of $E$ that are separable over $K$ (which can be shown is a (separable) subfield of $E$).  I would like to show that the implication     $\left[E:K\right]_s &lt; \infty \implies \left[E_s:K\right] &lt; \infty$   holds, where $\left[E:K\right]_s$ denotes the separable degree of $E/K$ and $\left[E_s:K\right]$ the 'ordinary' degree of $E_s/K$.  In the textbook I am learning with, it is said that one could use the Primitive Element Theorem to do this, but I would also be fine with any other approach, as long as it's not getting too fancy and staying in the realm of 'common' textbook theorems known when dealing with separable extensions (and I didn't see how the Primitive Element Theorem would help).  This is not my focus (I want to write a Bachelor's thesis about polynomial factorizing elements of $\mathbb{Z}[X]$), but I'm in the process of reading into commutative algebra after about 1.5 years break from it.  My idea was something like assuming $\left[E_s:K\right] &lt; \infty$ and $\left[E_s:K\right] = \infty$ to construct infinitely many $K$-homomorphisms $E_s/K \longrightarrow C/K$, where $C$ is some algebraic closure of $E_s$, which would then contradict $\left[E_s:K\right]_s = \left[E_s:K\right] &lt; \infty$. Of course, an infinite basis would yield infinitely many $K$-vector space homomorphisms, but getting (infinitely many) ring morphisms seems to by an entirely different ting (unsurprisingly so...). Thought of using something like     Given two roots of the minimal polynomial of one of the infinitely many elements of a $K$-basis of $E_s/K$, there is a $K$-morphism $E_s/K \longrightarrow C/K$ that sends one to the other.   but this didn't seem very fruitful. I admit I haven't spent hours on this, I just didn't get very far and should focus on moving on, while still getting an answer on the 'howto' along the road would be really nice. What is an example of a transformation on a posterior distribution such that the MAP estimate will be non-invariant? Suppose that we have a posterior distribution $p(\theta\mid y)$ and we wish to define a transformation on $\theta$ such that $\phi = f(\theta)$. I know that generally such transformations will not affect the MLE as it is on the data space, but will result in non-invariance on the Maximum A Posteriori (MAP) estimate as it is a function of the parameter space. I am wondering if there is an example to illustrate this? Thanks.