W3C home > Mailing lists > Public > html-tidy@w3.org > July to September 2001

Question about Tidy

From: Marco Spinetti <m.spinetti@pisa.iol.it>
Date: Fri, 14 Sep 2001 03:50:44 -0400 (EDT)
Message-ID: <004701c13cf2$37712a40$5be94cc1@pisa.iol.it>
To: <html-tidy@w3.org>
Hi all,
I'm a italian student and I am doing the thesis in Java. In one of my files I use Tidy.jar but I have a big problem. 
I take a string (<p>...here formated text......</p><p>.....</p>) where the spaces have been replaced by &nbsp;. 
My purpose is to build a Xml document of this form:

<page>
.....
<descr><p>...here formated text......</p><p>.....</p></descr>

</page>

To do this, my idea is build a Xml document with the taken string:

String document = "><p>...here formated text......</p><p>.....</p>";
descrizione ="<descrizione>" + descrizione + "</descrizione>";
 
and parsing the document with tidy. I have tried to use this code :
 
              StringBufferInputStream in1 = new StringBufferInputStream(descrizione);
              Tidy tidy = new Tidy();
              tidy.setMakeClean(true);
              tidy.setXmlOut(true);
              tidy.setXmlTags(true);
              org.w3c.dom.Document doc1 = tidy.parseDOM(in1,null);
              Element body = (Element)doc1.getElementsByTagName("descrzione").item(0);
              NodeList ln = body.getChildNodes();
              Element descrizionee = doc1.createElement("descrizione");
              for (int i=0; i<ln.getLength();i++) {
                descrizionee.appendChild((Element)ln.item(i));
              }
 
 
but I obtain the following mistake:

org.w3c.dom.DOMException: DOM005 Wrong document

Why wrong document? I have tried to change the code but the error is always the same. 
Where is my error?
please help me. I am blocked with the thesis since many days for this mistake.
I hope that you will answer me. 
 
Best regards
 
Marco Spinetti 
Received on Monday, 17 September 2001 15:41:42 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:46 GMT