从网上找到一段解析html的代码,希望加上生成xml得功能,但不知为什么生成结果如下:<?xml version="1.0" encoding="GBK"?>
<list>
</list>if语句里面得内容没有输出来,希望高手指正。package html;
import org.cyberneko.html.parsers.DOMParser; 
import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap; 
import org.w3c.dom.Node; 
import java.io.*;
public class testnekohtml 
{
public static void main(String[] argv) throws Exception 

  DOMParser parser = new DOMParser(); 
  System.setProperty("http.proxyHost", "88.148.41.44"); 
  System.setProperty("http.proxyPort", "51966"); 
  parser.setFeature("http://xml.org/sax/features/namespaces", false); 
 // parser.parse("c:/aa.jsp");//也可以是如:http://www.searchfull.net/blog
  //parser.parse("http://www.baidu.com");
  parser.parse("d:/126.htm");
  print(parser.getDocument(), ""); 
}
////////////////
public static void print(Node node, String indent) 

try
{
  // System.out.println(indent+node.getClass().getName()); 
 // System.out.println(node.getNodeName());
File f = new File("d:/shit.xml");
FileWriter fw = new FileWriter(f);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("<?xml version=\"1.0\" encoding=\"GBK\"?>");
bw.newLine();
bw.write("<list>");
bw.newLine();
if ("INPUT".equals(node.getNodeName())||"input".equals(node.getNodeName())||"Input".equals(node.getNodeName()))
{
bw.write("<list>");
String name=node.getNodeName();
NamedNodeMap map=node.getAttributes();//获得标记中属性的集合
// String content=node.getTextContent();
//System.out.println(name);
for(int k=0;k<map.getLength();k++)
{
Attr attrNode=(Attr)map.item(k);
String attName=attrNode.getName();
String attValue=attrNode.getValue();
bw.write("<");
System.out.println("0");
bw.write(name+" ");
bw.write("  "+attName+"="+attValue);
bw.write(">");
bw.newLine();
//System.out.println("  "+attName+"="+attValue);
}//
// System.out.println(content); 
}
Node child = node.getFirstChild(); 
while (child != null) 

print(child, indent + " "); 
child = child.getNextSibling(); 
}   
bw.write("</list>");
bw.close();
fw.close();
}//try
catch(IOException e)
{
System.out.println("输出异常");
}
}
}//main