Wie man es vermeidet, HTML- und Kopf -Tags in JSOUP Parse umzingelnHTML

HTML-Programmierer
Anonymous
 Wie man es vermeidet, HTML- und Kopf -Tags in JSOUP Parse umzingeln

Post by Anonymous »

Mit JSOUP versuche ich, den angegebenen HTML -Inhalt zu analysieren. Nach jSOUP.PARSE () findet die HTML -Ausgabe HTML , head und body zum Eingang an. Ich möchte diese nur ignorieren.

Code: Select all

[b]This [i]is[/i][/b] [i]my sentence[/i] of text.
[b]< /code>
Java-Code: < /p>
import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class HTMLParse {

public static void main(String args[]) throws IOException {
try{
File input = new File("/ab.html");
String html = FileUtils.readFileToString(input, null);

Document doc = Jsoup.parseBodyFragment(html);
doc.outputSettings().prettyPrint(false);
System.out.println(doc.html());
}
catch(Exception e){
e.printStackTrace();
}
}
}
Tatsächliche Ausgabe:

Code: Select all

This [i]is[/i][/b] [i]my sentence[/i] of text.
[b]    
Erwartete Ausgabe:

Code: Select all

This [i]is[/i][/b] [i]my sentence[/i] of text.
Wie kann ich JSOUP daran hindern, diese Tags hinzuzufügen?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post