私はhtmlドキュメントの操作に関するプロジェクトを行っています。既存のhtmlドキュメントの本文コンテンツを新しいhtmlに変更したいのですが、現在はJDOMを使用しています。コーディングでbody要素を使用したい。そのためにコーディングでgetChild( "body")を使用した。しかし、プログラムにnullが返される。しかし、htmlドキュメントにはbody要素が含まれている。私は学生です?
ポインタをいただければ幸いです。
コーディング:
import org.jdom.Document;
import org.jdom.Element;
public static void getBody() {
SAXBuilder builder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser", true);
org.jdom.Document jdomDocument=builder.build("http://www......com");
Element root = jdomDocument.getRootElement();
//It returns null
System.out.println(root.getChild("body"));
}
これらも参照してください..コンソールに出力された私のhtmlのルートと子...
root.getName():html
SIZE:2
[Element: <head [Namespace: http://www.w3.org/1999/xhtml]/>]
[Element: <body [Namespace: http://www.w3.org/1999/xhtml]/>]