java 出现错误:org.xml.sax.SAXParseException: 10
源代码如下:publicstaticvoidmain(String[]args)throwsException{getDocs("http://www.sport.gov...
源代码如下:
public static void main(String[] args) throws Exception {
getDocs("http://www.sport.gov.cn/n16/n1152/n2523/n377583","GB2312","/n907071.doc");
}
public static void getDocs(String url, String pageEncoding,String filename) {
try {
NodeFilter bodyfilter = new TagNameFilter("a"); // 过滤出头标签
Parser parser = new Parser(url);
//parser.setEncoding("GB2312");
parser.setEncoding(pageEncoding);
NodeList bodyList = parser.parse(bodyfilter);
if (bodyList != null && bodyList.size() > 0) {
String F = HtoX.tagBalance(bodyList.toHtml());
System.out.println(F);
-------------------------
我想下载其中为A标签的内容,但出现错误,错误信息如下:
[Fatal Error] :1:126: The markup in the document following the root element must be well-formed.
org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at services.GetDoc.getDocs(GetDoc.java:43) 展开
public static void main(String[] args) throws Exception {
getDocs("http://www.sport.gov.cn/n16/n1152/n2523/n377583","GB2312","/n907071.doc");
}
public static void getDocs(String url, String pageEncoding,String filename) {
try {
NodeFilter bodyfilter = new TagNameFilter("a"); // 过滤出头标签
Parser parser = new Parser(url);
//parser.setEncoding("GB2312");
parser.setEncoding(pageEncoding);
NodeList bodyList = parser.parse(bodyfilter);
if (bodyList != null && bodyList.size() > 0) {
String F = HtoX.tagBalance(bodyList.toHtml());
System.out.println(F);
-------------------------
我想下载其中为A标签的内容,但出现错误,错误信息如下:
[Fatal Error] :1:126: The markup in the document following the root element must be well-formed.
org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at services.GetDoc.getDocs(GetDoc.java:43) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询