Hallo,
Ich habe ein Problem! wenn du mir vielleicht helfen kannst!
Ich habe versucht die so gennante JTidy innerhalb einen Thread "run()-Methode" ins Laufen zu lassen. Es funktioniert, aber bekomme ich im Trace kein richtiges Dokument! sondern es schaut so wie folgt aus:
org.w3c.tidy.DOMDocumentImpl@e746a2
org.w3c.tidy.DOMDocumentImpl@1ce56f8
line 1 column 5 - Warning: replacing illegal character code 131
line 1 column 5 - Warning: replacing illegal character code 131
org.w3c.tidy.DOMDocumentImpl@5bece2
org.w3c.tidy.DOMDocumentImpl@11cf4e5
org.w3c.tidy.DOMDocumentImpl@121e5a
Characters codes for the Microsoft Windows fonts in the range
128 - 159 may not be recognized on other platforms. You are
instead recommended to use named entities, e.g. ™ rather
than Windows character code 153 (0x2122 in Unicode). Note that
as of February 1998 few browsers support the new entities."
line 1 column 1 - Warning: unexpected </head>
org.w3c.tidy.DOMDocumentImpl@3abc87
org.w3c.tidy.DOMDocumentImpl@2f5dda
org.w3c.tidy.DOMDocumentImpl@1bad2e8
org.w3c.tidy.DOMDocumentImpl@6c8255
org.w3c.tidy.DOMDocumentImpl@1e0bf98
org.w3c.tidy.DOMDocumentImpl@42bb13
line 1 column 22 - Warning: replacing illegal character code 131
line 1 column 159 - Warning: unexpected </a> in <img>
This document has errors that must be fixed before
using HTML Tidy to generate a tidied up version.
line 1 column 201 - Warning: unexpected </a> in <img>
line 1 column 205 - Warning: unexpected </noscript> in <img>
This document has errors that must be fixed before
using HTML Tidy to generate a tidied up version.
...
--------
hier ist mein Code:
//JTidy
Tidy tidy = new Tidy();
tidy.setMakeClean( true ); // Ohne Störungen
tidy.setXmlTags( false ); // Eingabe als XML behandeln
URL url;
try {
url = new URL( hier ist die
http://... );
Reader inputStream = new InputStreamReader( url.openStream() );
BufferedReader in = new BufferedReader( inputStream );
for ( String s; ( s = in.readLine() ) != null; ){
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes("UTF-8"));
org.w3c.dom.Document doc = tidy.parseDOM( is, null );
System.out.println(doc);
}
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Ich verstehe nicht, was macht wirklich die Tidy!
Also, Was ich möchte ist folgendes:
1. Ich lese aus einer Webseite die HTML-Struktur.
2. Da die Struktur nicht wohlgeformt ist, muss man sie umwandeln z.B. in XHTL!
3. Für diese Umwandelugn brauchen wir die JTidy.
Als Ergebnis muss man die wohlgeformte HTML-Struktur (gennant; XHTML) bekommen! Aber es tut nicht!!
Ich werde sehr dankbar, wenn Du mir helfen kannst.
schöne Grüße,
Hama