java配的工具类足够,下载安装QQ,然后搜索安装目录下LocList.xml文件
以下就是解析这个文件的代码,输出为一堆sql,你懂得,如果要json对象
那修改printNode就可以了
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class TestXML {
private static void printNode(Node n, Node parent, int level ) {
parent = parent==null? n:parent;
System.out.println("insert into world_country(id,name, pid, level)values( "
+ n.getAttributes().getNamedItem("Code").getNodeValue()+","
+ "\""+ n.getAttributes().getNamedItem("Name").getNodeValue()+"\","
+ "\""+ parent.getAttributes().getNamedItem("Code").getNodeValue() +"