简介 目录 评价 推荐
  • 程序员慕虎 2019-11-07

    JDOM中存储Book对象

    http://img3.mukewang.com/5dc3cefe0001c01f08230404.jpg

    0赞 · 0采集
  • BirdOfV 2018-05-22

    在JDOM中存储对象
    1.创建一个新的book类并将其实例化
    Book bookEntity = new Book();
    2.添加节点属性值到book
    if(attrName.equals("id")){
    personEntity.setId(attrValue);
    }
    3.添加子节点属性值到book
    if (child.getName().equals("name")) {
    bookEntity.setName(child.getValue());
    }
    else if (child.getName().equals("author")) {
    bookEntity.setAuthor(child.getValue());
    }
    else if (child.getName().equals("year")) {
    bookEntity.setYear(child.getValue());
    }
    else if (child.getName().equals("price")) {
    bookEntity.setPrice(child.getValue());
    }
    else if (child.getName().equals("language")) {
    bookEntity.setLanguage(child.getValue());
    }

    0赞 · 0采集
  • 690017359 2017-11-22
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } 4.存储对象的值 用数据组List ArrayList
    0赞 · 1采集
  • 小光头 2017-09-26
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } 4.存储对象的值 用数据组List ArrayList
    0赞 · 0采集
  • 木木嗷 2017-09-15
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } else if (child.getName().equals("year")) { bookEntity.setYear(child.getValue()); } else if (child.getName().equals("price")) { bookEntity.setPrice(child.getValue()); } else if (child.getName().equals("language")) { bookEntity.setLanguage(child.getValue()); }
    0赞 · 0采集
  • 慕粉5101576 2017-07-19
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } else if (child.getName().equals("year")) { bookEntity.setYear(child.getValue()); } else if (child.getName().equals("price")) { bookEntity.setPrice(child.getValue()); } else if (child.getName().equals("language")) { bookEntity.setLanguage(child.getValue()); }
    0赞 · 0采集
  • 滕玉龙 2017-02-16
    ***********运行结果貌似不符********** ====开始解析第1书==== 属性名:id---属性值:1 节点名:name节点值:冰与火之歌 节点名:author节点值:乔治马丁 节点名:year节点值:2014 节点名:price节点值:89 ====结束解析第1书==== 1 1 name ====开始解析第2书==== 属性名:id---属性值:2 节点名:name节点值:安徒生童话 节点名:year节点值:2004 节点名:price节点值:77 节点名:language节点值:English ====结束解析第2书==== 2 1 name
    截图
    0赞 · 0采集
  • 滕玉龙 2017-02-16
    if(attrName.equals("id")){ bookEntity.setId(attrValue); } } // 对book节点的子节点的节点名以及节点值的遍历 List<Element> bookChilds = book.getChildren(); for (Element child : bookChilds) { System.out.println("节点名:" + child.getName() + "节点值:" + child.getValue()); if(child.getName().equals("name")){ bookEntity.setName(child.getName()); } else if(child.getName().equals("author")){ bookEntity.setAuthor(child.getValue()); } else if(child.getName().equals("year")){ bookEntity.setYear(child.getValue()); } else if(child.getName().equals("price")){ bookEntity.setPrice(child.getValue()); } else if(child.getName().equals("language")){ bookEntity.setLanguage(child.getValue()); } }
    截图
    0赞 · 0采集
  • 滕玉龙 2017-02-16
    package com.imooc.entity; public class Book { private String id; private String name; private String author; private String year; private String price; private String language; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getYear() { return year; } public void setYear(String year) { this.year = year; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public String getLanguage() { return language; } public void setLanguage(String language) { this.language = language; } }
    截图
    0赞 · 0采集
  • qq_初时模样_04350133 2017-01-05
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } else if (child.getName().equals("year")) { bookEntity.setYear(child.getValue()); } else if (child.getName().equals("price")) { bookEntity.setPrice(child.getValue()); } else if (child.getName().equals("language")) { bookEntity.setLanguage(child.getValue()); }
    0赞 · 0采集
  • 章鱼锐锐4416831 2016-12-21
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } else if (child.getName().equals("year")) { bookEntity.setYear(child.getValue()); } else if (child.getName().equals("price")) { bookEntity.setPrice(child.getValue()); } else if (child.getName().equals("language")) { bookEntity.setLanguage(child.getValue()); }
    0赞 · 0采集
  • 皮皮虾我们_走 2016-11-26
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } else if (child.getName().equals("year")) { bookEntity.setYear(child.getValue()); } else if (child.getName().equals("price")) { bookEntity.setPrice(child.getValue()); } else if (child.getName().equals("language")) { bookEntity.setLanguage(child.getValue()); }
    0赞 · 0采集
  • Dicrector 2016-09-08
    解决JDOM解析xml文件出现的乱码问题: 1. inputStreamReader isr =new inputStreamReader(创建的fileInputStream的文件名,编码方式); 2. SAXParserBuilder.build(isr);
    0赞 · 0采集
  • qq_你要是在麦田里遇到我_0 2016-08-17
    个人观点,希望说能对其他后来的学员能够有点帮助吧。怎么说呢,希望大家不要喷我。当然还是给所有的初学者一些建议 我觉得初学者是怎样的一个群体? 1.不会自己查api(更甚者不知道什么是api) 2.不了解java编程的基本概念 3.不会使用eclipse提供的基本快捷方式 4.没有一定的基础,没有对java的基本认知 5.对java提供的类和方法没有基本的熟悉(用过,试过) 6.没有经历过任何项目,没有参与或者见识过比较高级的开发模式,甚至不知道有这个概念 我对初学者的建议: 1.起码弄清getset吧,笔记里面竟然还有这个,我觉得很尴尬,你完全不懂他的意思???最基础的还要备注? 2.从前面的java基础开始学习,不只是学习,还要理解,实践,如果你以后要靠这个吃饭 3.推荐之后可以去看百度传课的《javaSe核心技术》:对java类更深入的应用 4.书籍推荐《JAVA编程思想》。有一定基础的可以去看 5.接触项目,学习框架 6.查缺补漏 我说的话不中听,但是实用,希望靠JAVA来生活的可以看看
    11赞 · 4采集
  • 慕粉3170877 2016-08-09
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } else if (child.getName().equals("year")) { bookEntity.setYear(child.getValue()); } else if (child.getName().equals("price")) { bookEntity.setPrice(child.getValue()); } else if (child.getName().equals("language")) { bookEntity.setLanguage(child.getValue()); }
    0赞 · 0采集
  • 小浩233 2016-07-25
    在 JDOM 中存储 Book 对象 private static ArrayList<Book> booksList = new ArrayList<Book>(); ... // 遍历attrList(针对不清楚book节点下属性的名字及数量) for (Attribute attr : attrList) { // 属性名 String attrName = attr.getName(); // 属性值 String attrValue = attr.getValue(); System.out.println("属性名:" + attrName + "属性值:" + attrValue); if (attrName.equals("id")) { bookEntity.setId(attrValue); } } // 对book节点的子节点的节点名及节点值的遍历 List<Element> bookChilds = book.getChildren(); for (Element child : bookChilds) { System.out.println("节点名:" + child.getName() + "节点值:" + child.getValue()); if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } ...//else if(){}与上面类似 booksList.add(bookEntity); bookEntity = null; syso.booksList.size(); syso.booksList.get(0).getId(); syso.booksList.get(0).getName(); ...
    0赞 · 1采集
  • 夜还没黑 2016-06-21
    在JDOM中存储对象 1.创建一个新的book类并将其实例化 Book bookEntity = new Book(); 2.添加节点属性值到book if(attrName.equals("id")){ personEntity.setId(attrValue); } 3.添加子节点属性值到book if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } else if (child.getName().equals("year")) { bookEntity.setYear(child.getValue()); } else if (child.getName().equals("price")) { bookEntity.setPrice(child.getValue()); } else if (child.getName().equals("language")) { bookEntity.setLanguage(child.getValue()); }
    0赞 · 0采集
  • 霜花似雪 2016-03-26
    ---------------------------------在JDOM中存储Person对象--------------------------------- Person personEntity = new Person(); if(attrName.equals("id")){ personEntity.setId(attrValue); } if(child.getName().equals("name")){ personEntity.setName(child.getValue()); }else if(child.getName().equals("sex")){ personEntity.setSex(child.getValue()); }else if{ ... } private static ArrayList<Person> arrayList = new ArrayList(); arrayList.add(personEntity); //将personEntity设置为空,让垃圾回收机制回收 personEntity = null;
    截图
    0赞 · 2采集
  • Java张 2016-02-27
    当对象使用后,将对象置为null,交给垃圾回收机制去处理。
    0赞 · 0采集
  • Jde冻结 2016-02-26
    add book进list 然后讲book的引用置为null 以后下一次循环来使用
    截图
    0赞 · 1采集
  • Jde冻结 2016-02-26
    new一个list来存储多个book对象
    截图
    0赞 · 1采集
  • Jde冻结 2016-02-26
    在解析到的子节点中setField
    截图
    0赞 · 0采集
  • Jde冻结 2016-02-26
    在解析到的属性中setId
    截图
    0赞 · 0采集
  • Jde冻结 2016-02-26
    new一个book
    截图
    0赞 · 0采集
  • 梦编猿 2016-02-01
    在 JDOM 中存储 Book 对象 private static ArrayList<Book> booksList = new ArrayList<Book>(); ... // 遍历attrList(针对不清楚book节点下属性的名字及数量) for (Attribute attr : attrList) { // 属性名 String attrName = attr.getName(); // 属性值 String attrValue = attr.getValue(); System.out.println("属性名:" + attrName + "属性值:" + attrValue); if (attrName.equals("id")) { bookEntity.setId(attrValue); } } // 对book节点的子节点的节点名及节点值的遍历 List<Element> bookChilds = book.getChildren(); for (Element child : bookChilds) { System.out.println("节点名:" + child.getName() + "节点值:" + child.getValue()); if (child.getName().equals("name")) { bookEntity.setName(child.getValue()); } else if (child.getName().equals("author")) { bookEntity.setAuthor(child.getValue()); } ...//else if(){}与上面类似 booksList.add(bookEntity); bookEntity = null; syso.booksList.size(); syso.booksList.get(0).getId(); syso.booksList.get(0).getName(); ...
    0赞 · 6采集
  • linyih 2015-08-11
    Person personEntity = new Person(); if(attrName.equals("id")){ personEntity.setId(attrValue); } if(child.getName().equals("name")){ personEntity.setName(child.getValue()); }else if(child.getName().equals("sex")){ personEntity.setSex(child.getValue()); }else if{ ... } private static ArrayList<Person> arrayList = new ArrayList(); arrayList.add(personEntity); //将personEntity设置为空,让垃圾回收机制回收 personEntity = null;
    0赞 · 0采集
  • Object_is_null 2015-08-03
    在JDOM中存储对象, Person personEntity = new Person(); if(attrName.equals("id")){ personEntity.setId(attrValue); } if(child.getName().equals("name")){ personEntity.setName(child.getValue()); }else if(child.getName().equals("sex")){ personEntity.setSex(child.getValue()); }else if{ ... }
    0赞 · 0采集
  • Refactor易先生 2015-08-02
    为了节约资源,就把bookEntity设置为空。
    截图
    0赞 · 1采集
  • _Mok 2015-06-23
    1.創建Book類 2.外層for循環,每次循環創建一個Book對象。 Book bookSet = new Book(); 獲取屬性 if (attrName.equals("id") {bookSet.setId(attrValue);} 3.Book的子節點的節點名與屬性 if (booknodes.getName.equals("name")) {bookSet.SetName(booknodes.getValue);} else if (booknodes.getName.equals("author")) {bookSet.SetAuthor(booknodes.getValue);} ... 4.將得到嘅Book對象bookSet存入List入邊 在方法外,類內定義,private static ArrayList<Book> booksList = new ArrayList<Book>(); 在外層for循環結束處,booksList.add(bookSet);bookSet = null;
    0赞 · 0采集
  • 南流江畔人家 2015-06-17
    在JDOM中存储对象, Person personEntity = new Person(); if(attrName.equals("id")){ personEntity.setId(attrValue); } if(child.getName().equals("name")){ personEntity.setName(child.getValue()); }else if(child.getName().equals("sex")){ personEntity.setSex(child.getValue()); }else if{ ... }
    0赞 · 4采集
数据加载中...
开始学习 免费