zoukankan      html  css  js  c++  java
  • jdom解析

    package ioXml;
    
    import java.io.File;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.Set;
    
    import javax.swing.text.StyledEditorKit.ItalicAction;
    
    import org.jdom.Attribute;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.input.*;
    
    public class IoXmlRead {
        
        
        static Map <String ,String> xmlMap=new HashMap<String, String>();
        public static void main(String[] args) {
            
            preCrElement();
            
            Set<String> hh=xmlMap.keySet();
            Iterator<String> i=hh.iterator();
            while(i.hasNext()){
                String key = i.next();
                String value = xmlMap.get(key);
                System.out.println(key+":"+value);
            }
        }
        
        public static void preCrElement(){
            
            SAXBuilder builder = new SAXBuilder();
            try {
                Document doc = builder.build(new File("E:/Users/Administrator/workspace/GFJ/src/art.xml"));
                Element root = doc.getRootElement();
                createElement(root);
            } catch (JDOMException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }      
        }
        public static void createElement(Element e){
            
            Element pre = e.getChild("protest");
            List<Element> list=e.getChildren();
            if(list!=null && list.size()>0){
                for(Element ele : list){
                    createElement(ele);
                }
            }else{
                Element el=(Element) e.getParent();
                Element jir = e;
                String name = e.getName();
                String nodeText = jir.getText();
                xmlMap.put(name,nodeText);
            }
            
            
            
        }
        
    
    }
  • 相关阅读:
    MySQL:procedure, function, cursor,handler
    Spring:ApplicationContext (2)
    Dojo: Quick Start
    Linux:常用命令
    Squirrel: 通用SQL、NoSQL客户端
    湖南师范大学邮箱申请及
    一文读懂基因测序技术的前世今生
    一 二 三代测序技术
    浅议基因测序技术的代际:后记
    浅议基因测序技术的代际
  • 原文地址:https://www.cnblogs.com/bashala/p/3759789.html
Copyright © 2011-2022 走看看