ページの HTML コードを取り込み、ページの特定の要素 (テーブルなど) を抽出し、それらの要素の HTML コードを返すアプリを作成しています。ページのナビゲーションを簡素化するために Mozilla パーサーを使用して Java でこれを実行しようとしていますが、必要な html コードを抽出するのに問題があります。
たぶん、私のアプローチ全体、別名 Mozilla パーサーが間違っているので、より良い解決策があれば、提案をお待ちしています
String html = ///what ever the code is
MozillaParser p = // instantiate parser
// pass in html to parse which creates a dom object
Document d = p.parse(html);
// get a list of all the form elements in the page
NodeList l = d.getElementsByTagName("form");
// iterate through all forms
for(int i = 0; i < l.getLength(); i++){
// get a form
Node n = l.item(i);
// print out the html code for just this form.
// This is the portion I haven't figured out.
// I just made up the innerHTML method, but thats
// the end result I'm desiring, a way to just see
// the html code for a particular node
System.out.println( n.innerHTML() );
}