zoukankan      html  css  js  c++  java
  • 1.xml解析

    public static void main(String[] args) throws DocumentException {
            SAXReader saxReader = new SAXReader();
            Document read = saxReader.read(new File("E://work//spring-ioc//src//main//resources//stu.xml"));
            // 获取根节点
            Element rootElement = read.getRootElement();
            getNodes(rootElement);
     
            }
     
    static public void getNodes(Element rootElement) {
            System.out.println("当前节点名称:" + rootElement.getName());
            // 获取属性ID
            List<Attribute> attributes = rootElement.attributes();
            for (Attribute attribute : attributes) {
            System.out.println("属性:" + attribute.getName() + "---" + attribute.getText());
            }
            if (!rootElement.getTextTrim().equals("")) {
            System.out.println(rootElement.getName() + "--" + rootElement.getText());
            }
            // 使用迭代器遍历
            Iterator<Element> elementIterator = rootElement.elementIterator();
            while (elementIterator.hasNext()) {
            Element next = elementIterator.next();
            getNodes(next);
            }
     
            }

  • 相关阅读:
    jchdl
    jchdl
    jchdl
    jchdl
    jchdl
    jchdl
    jchdl
    UVa 437 (变形的LIS) The Tower of Babylon
    UVa 1025 (动态规划) A Spy in the Metro
    UVa 10129 (并查集 + 欧拉路径) Play on Words
  • 原文地址:https://www.cnblogs.com/goldlong/p/10966010.html
Copyright © 2011-2022 走看看