converttoxml.java~31~
来自「本程序用JAVA编制」· JAVA~31~ 代码 · 共 30 行
JAVA~31~
30 行
import org.xml.sax.*;import org.w3c.dom.*;import org.apache.xerces.dom.*;import org.apache.xerces.parsers.*;import org.apache.xml.serialize.*;// Import packages dealing with XSL transformationimport org.apache.xalan.xslt.*;import org.apache.xalan.xpath.*;// Import the Tidy package for HTML to XML transformationimport org.w3c.tidy.*;/** * Retrieve an HTML page, convert the source to XML, * and write the result to a file. */public class convertToXml { public static void main(String args[]) { try { //Document doc = XMLHelper.tidyHTML("http://weather.yahoo.com/forecast/UKXX0085_c.html?force_units=1"); //Document doc = StockHelper.tidyHTML("http://stock.sina.com.cn/cgi-bin/stock/quote/quote.cgi?symbol=600002&country=sh&option=1"); Document doc = StockHelper.tidyHTML("http://news.sina.com.cn/#china"); XMLHelper.outputXMLToFile(doc,"new-xml/news1.xml"); }catch(XMLHelperException xmle){ xmle.printStackTrace(); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?