<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Andrea<br>
    <br>
    As others have said, JDOM ensures that the output from the
    XMLOutputter is valid XML. The raw string '&test' is not valid
    XML.<br>
    <br>
    You do have options. If you really want the raw string, then perhaps
    you want to enclose it in a CDATA section.<br>
    <br>
    CDATA cdata = new CDATA("&test");<br>
    Element element = new Element("root");<br>
    element.addContent(cdata);<br>
    xmloutputter.output(stream,element);<br>
    <br>
    <root><[CDATA[&test]]></root><br>
    <br>
    That may give you what you want, and it will also be valid XML.<br>
    <br>
    If you want to skip the CDATA section then you can probably put a
    filtering system between JDOM's output stream and the final
    destination stream. That 'filter' can search/replace specific
    content with invalid XML content....<br>
    <br>
    Otherwise you can create your own custom XMLOutputter instance that
    'breaks' the validation process for Text content.<br>
    <br>
    Rolf<br>
    <br>
    On 16/12/2011 6:58 AM, Andrea Pacini wrote:
    <blockquote
cite="mid:CACjey_FW-uSvvkixBLY=2bRbVr8Un_DEJBx23ko05ewzUAYUKw@mail.gmail.com"
      type="cite">
      <div class="gmail_quote">
        <blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px
          0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
          <div>We have necessity to write, in the final XML, the string
            &test and not the string &amp;test</div>
          <div>How can we do ?<br>
            <br>
          </div>
          <div class="gmail_quote">2011/12/16 Grzegorz <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:grzegorz.kaczor@gmail.com" target="_blank">grzegorz.kaczor@gmail.com</a>></span><br>
            <blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px
              0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
              <div class="gmail_quote">
                <blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px
                  0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">according
                  to Jdom FAQ ( <a moz-do-not-send="true"
                    href="http://www.jdom.org/docs/faq.html#a0290"
                    target="_blank">http://www.jdom.org/docs/faq.html#a0290</a>
                  ) , I tried to write the string<br>
                   <br>
                  &test<br>
                   <br>
                  using this statement:<br>
                   <br>
                  root.setText("\u0026test");<br>
                   <br>
                  where \u0026 is the Unicode code for ampersand
                  character.<br>
                   <br>
                  The output is:<br>
                   <br>
                  &amp;test<br>
                   <br>
                  Where is the error ? <br>
                </blockquote>
                <div><br>
                </div>
                <div>There is no error. What is wrong? It is a special
                  character in XML and as such it must be escaped.</div>
                <div><br>
                </div>
                <div>Regards,</div>
                <span><font color="#888888">
                    <div>Grzegorz</div>
                  </font></span></div>
            </blockquote>
          </div>
          <br>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>