Dom4j 学习笔记

dom4j 是一种解析 XML 文档的开放源代码 XML 框架。dom4j下载地址
本文主要记载了一些简单的使用方法。

一、xml文件的解析

dom4j既可以解析普通的xml文件,也可以解析一个InputStream,先看看xml文件长什么样子:

<books><book><id>1</id><name>Java编程思想</name><price>80</price><author>张三</author></book><book><id>2</id><name>三国演义</name><price>30</price><author>罗贯中</author></book><book><id>3</id><name>红楼梦</name><price>35</price><author>曹雪芹</author></book><book><id>4</id><name>西游记</name><price>25</price><author>吴承恩</author></book><book><id>5</id><name>水浒传</name><price>30</price><author>施耐庵</author></book>
</books>

通过读取这一段xml文件并解析,将xml文件中的内容存储到javabean中。

    private List<Book> bs;private Book b;//读取xml文件获得Document对象@Testpublic void test1(){try {//1.读取xml文件,获取document对象SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));//2.获取根节点<books>Element root = document.getRootElement();bs = new ArrayList<Book>();//3.迭代,获取根节点的所有子节点<book>for (Iterator<Element> es = root.elementIterator(); es.hasNext();) {Element e = es.next();b = new Book();//4.再次迭代,获取子节点的子节点<id><name><price><author>for (Iterator<Element> e_son = e.elementIterator();e_son.hasNext();) {Element ee = e_son.next();if(ee.getName().equals("id")){b.setId(Integer.parseInt(ee.getText().toString()));}else if(ee.getName().equals("name")){b.setName(ee.getText());}else if(ee.getName().equals("price")){b.setPrice(Integer.parseInt(ee.getText()));}else if(ee.getName().equals("auhtor")){b.setAuthor(ee.getText());}}bs.add(b);}} catch (DocumentException e) {e.printStackTrace();}for (Book bk : bs) {System.out.println(bk.getName());}}

Book.java

public class Book {private int id;private String name;private int price;private String author;private Detail detail;private Attribute attribute;public Attribute getAttribute() {return attribute;}public void setAttribute(Attribute attribute) {this.attribute = attribute;}public Detail getDetail() {return detail;}public void setDetail(Detail detail) {this.detail = detail;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getPrice() {return price;}public void setPrice(int price) {this.price = price;}public String getAuthor() {return author;}public void setAuthor(String author) {this.author = author;}
}

Attribute.java

public class Attribute {private String category;private String edition;public String getCategory() {return category;}public void setCategory(String category) {this.category = category;}public String getEdition() {return edition;}public void setEdition(String edition) {this.edition = edition;}}

Detail.java

public class Detail {private String pressTime;private String storyTime;public String getPressTime() {return pressTime;}public void setPressTime(String pressTime) {this.pressTime = pressTime;}public String getStoryTime() {return storyTime;}public void setStoryTime(String storyTime) {this.storyTime = storyTime;}
}

这里写图片描述

好,我们稍微修改一下xml文件,再看看个该如何解析:

<books><book><id>1</id><name>Java编程思想</name><price>80</price><author>张三</author><detail><pressTime>天朝</pressTime><storyTime>21世纪</storyTime></detail></book><book><id>2</id><name>三国演义</name><price>30</price><author>罗贯中</author><detail><pressTime>明朝</pressTime><storyTime>汉末</storyTime></detail></book><book><id>3</id><name>红楼梦</name><price>35</price><author>曹雪芹</author><detail><pressTime>清朝</pressTime><storyTime>不详</storyTime></detail></book><book><id>4</id><name>西游记</name><price>25</price><author>吴承恩</author><detail><pressTime>明朝</pressTime><storyTime>大唐</storyTime></detail></book><book><id>5</id><name>水浒传</name><price>30</price><author>施耐庵</author><detail><pressTime>明朝</pressTime><storyTime>大宋</storyTime></detail></book>
</books>

又多了一层嵌套,看解析方式:

    private List<Book> bs;private Book b;private Detail detail;// 读取xml文件获得Document对象@Testpublic void test1() {try {// 1.读取xml文件,获取document对象SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));// 2.获取根节点<books>Element root = document.getRootElement();bs = new ArrayList<Book>();// 3.迭代,获取根节点的所有子节点<book>for (Iterator<Element> es = root.elementIterator(); es.hasNext();) {Element e = es.next();b = new Book();// 4.再次迭代,获取子节点的子节点<id><name><price><author>for (Iterator<Element> e_son = e.elementIterator(); e_son.hasNext();) {Element ee = e_son.next();if (ee.getName().equals("id")) {b.setId(Integer.parseInt(ee.getText().toString()));} else if (ee.getName().equals("name")) {b.setName(ee.getText());} else if (ee.getName().equals("price")) {b.setPrice(Integer.parseInt(ee.getText()));} else if (ee.getName().equals("auhtor")) {b.setAuthor(ee.getText());} else if (ee.getName().equals("detail")) {detail = new Detail();for (Iterator<Element> ds = ee.elementIterator(); ds.hasNext();) {Element d = ds.next();if (d.getName().equals("pressTime")) {detail.setPressTime(d.getText());} else if (d.getName().equals("storyTime")) {detail.setStoryTime(d.getText());}}b.setDetail(detail);}}bs.add(b);}} catch (DocumentException e) {e.printStackTrace();}for (Book bk : bs) {System.out.println(bk.getName()+","+bk.getDetail().getPressTime());}}

继续修改xml文件,为之添加属性:

<books><book category="编程技术" edition="8"><id>1</id><name>Java编程思想</name><price>80</price><author>张三</author><detail><pressTime>天朝</pressTime><storyTime>21世纪</storyTime></detail></book><book category="历史小说" edition="1"><id>2</id><name>三国演义</name><price>30</price><author>罗贯中</author><detail><pressTime>明朝</pressTime><storyTime>汉末</storyTime></detail></book><book category="小说" edition="2"><id>3</id><name>红楼梦</name><price>35</price><author>曹雪芹</author><detail><pressTime>清朝</pressTime><storyTime>不详</storyTime></detail></book><book category="神话小说" edition="4"><id>4</id><name>西游记</name><price>25</price><author>吴承恩</author><detail><pressTime>明朝</pressTime><storyTime>大唐</storyTime></detail></book><book category="小说" edition="5"><id>5</id><name>水浒传</name><price>30</price><author>施耐庵</author><detail><pressTime>明朝</pressTime><storyTime>大宋</storyTime></detail></book>
</books>

给每一个book都添加了属性,又该怎么遍历呢?attribute的遍历和element的遍历非常类似,看代码:

    // 读取xml文件获得Document对象@Testpublic void test1() {try {// 1.读取xml文件,获取document对象SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));// 2.获取根节点<books>Element root = document.getRootElement();bs = new ArrayList<Book>();// 3.迭代,获取根节点的所有子节点<book>for (Iterator<Element> es = root.elementIterator(); es.hasNext();) {Element e = es.next();b = new Book();book_attr = new lenve.test.Attribute();for (Iterator<Attribute> as = e.attributeIterator();as.hasNext();) {Attribute attr = as.next();if(attr.getName().equals("category")){book_attr.setCategory(attr.getText());}else if(attr.getName().equals("edition")){book_attr.setEdition(attr.getText());}}b.setAttribute(book_attr);// 4.再次迭代,获取子节点的子节点<id><name><price><author>for (Iterator<Element> e_son = e.elementIterator(); e_son.hasNext();) {Element ee = e_son.next();if (ee.getName().equals("id")) {b.setId(Integer.parseInt(ee.getText().toString()));} else if (ee.getName().equals("name")) {b.setName(ee.getText());} else if (ee.getName().equals("price")) {b.setPrice(Integer.parseInt(ee.getText()));} else if (ee.getName().equals("auhtor")) {b.setAuthor(ee.getText());} else if (ee.getName().equals("detail")) {detail = new Detail();for (Iterator<Element> ds = ee.elementIterator(); ds.hasNext();) {Element d = ds.next();if (d.getName().equals("pressTime")) {detail.setPressTime(d.getText());} else if (d.getName().equals("storyTime")) {detail.setStoryTime(d.getText());}}b.setDetail(detail);}}bs.add(b);}} catch (DocumentException e) {e.printStackTrace();}for (Book bk : bs) {System.out.println(bk.getName()+","+bk.getDetail().getPressTime()+","+bk.getAttribute().getCategory());}}

如果我们只想遍历某一个节点呢?比如我们只想遍历名称为id的节点,该怎么办?

    private List<Book> bs;private Book b;@Testpublic void test2() {try {// 1.读取xml文件,获取document对象SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));// 2.获取根节点<books>Element root = document.getRootElement();bs = new ArrayList<Book>();// 3.迭代,获取根节点的所有子节点<book>for (Iterator<Element> es = root.elementIterator(); es.hasNext();) {Element e = es.next();b = new Book();// 4.再次迭代,获取子节点的子节点<id><name><price><author>for (Iterator<Element> e_son = e.elementIterator("id"); e_son.hasNext();) {Element ee = e_son.next();b.setId(Integer.parseInt(ee.getText().toString()));}bs.add(b);}} catch (DocumentException e) {e.printStackTrace();}for (Book bk : bs) {System.out.println(bk.getId()+","+bk.getAuthor());}}

输出:
这里写图片描述

最后一个问题,怎样以字符串的形式拿到一个xml文件:

    @Testpublic void test3(){try {SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));String text = document.asXML();System.out.println(text);} catch (DocumentException e) {e.printStackTrace();}}

二、使用程序写一个xml文件

1.怎样把一个字符串文件写成xml文件:

    @Testpublic void test4() {try {String text = "<fruits><fruit><name>苹果</name><color>red</color><price>3元</price></fruit></fruits>";Document document = DocumentHelper.parseText(text);//两种方式皆可
//          FileWriter out = new FileWriter(new File("F:\\test\\str2xml.xml"));PrintWriter out = new PrintWriter(new File("F:\\test\\s2x.xml"));document.write(out);out.close();} catch (DocumentException e) {e.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}

这样输出的xml文件没有格式,可读性较差,换个方式再看看:

    @Testpublic void test5() {try {String text = "<fruits><fruit><name>苹果</name><color>red</color><price>3元</price></fruit></fruits>";Document document = DocumentHelper.parseText(text);PrintWriter out = new PrintWriter(new File("F:\\test\\s2x1.xml"));XMLWriter writer = new XMLWriter(out, new OutputFormat().createPrettyPrint());writer.write(document);writer.close();} catch (DocumentException e) {e.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}

输出结果:
这里写图片描述

这样的输出格式也是极好的。

2.通过程序一个元素一个元素的写入:

    @Testpublic void test6(){int res = createXMLFile();if(res==1){System.out.println("xml文件创建成功!");}else{System.out.println("xml文件创建失败!");}}public int createXMLFile(){//返回0表示创建成功,返回1表示创建失败int result = 0;Document document = DocumentHelper.createDocument();//建立根节点Element root = document.addElement("fruits");//加入注释root.addComment("this is a xml about fruit");Element f1 = root.addElement("fruit");f1.addAttribute("color", "red");Element f11 = f1.addElement("price");f11.setText("10元");Element f12 = f1.addElement("shape");f12.setText("圆形");Element f13 = f1.addElement("name");f13.setText("苹果");//将xml写入文件中try {PrintWriter out = new PrintWriter(new File("F:\\test\\111.xml"));XMLWriter writer = new XMLWriter(out, new OutputFormat().createPrettyPrint());writer.write(document);writer.close();result = 1;} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return result;}

这里写图片描述

再看看新创建的xml文件长什么样:

这里写图片描述

这里使用最多的就是三个方法,一个是addElement(),一个是addAttribute(),还有一个是setText(),对每一个节点都可以执行这三个操作,你想创建的任何形状的xml都可以通过层层的嵌套实现。

如果想手动指定输出编码格式:

    @Testpublic void test6(){int res = createXMLFile();if(res==1){System.out.println("xml文件创建成功!");}else{System.out.println("xml文件创建失败!");}}public int createXMLFile(){//返回0表示创建成功,返回1表示创建失败int result = 0;Document document = DocumentHelper.createDocument();//建立根节点Element root = document.addElement("fruits");//加入注释root.addComment("this is a xml about fruit");Element f1 = root.addElement("fruit");f1.addAttribute("color", "red");Element f11 = f1.addElement("price");f11.setText("10元");Element f12 = f1.addElement("shape");f12.setText("圆形");Element f13 = f1.addElement("name");f13.setText("苹果");//将xml写入文件中try {PrintWriter out = new PrintWriter(new File("F:\\test\\111.xml"));OutputFormat format = OutputFormat.createPrettyPrint();//缩进显示//默认输出编码是UTF-8,可以手动设置为GBKformat.setEncoding("GBK");XMLWriter writer = new XMLWriter(out, format);writer.write(document);writer.close();result = 1;} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return result;}

输出的xml文件为(注意看编码):

这里写图片描述

三、修改xml文件

我们要修改一下xml文件:

<books><book category="编程技术" edition="8"><id>1</id><name>Java编程思想</name><price>80</price><author>张三</author><detail><pressTime>天朝</pressTime><storyTime>21世纪</storyTime></detail></book><book category="历史小说" edition="1"><id>2</id><name>三国演义</name><price>30</price><author>罗贯中</author><detail><pressTime>明朝</pressTime><storyTime>汉末</storyTime></detail></book><book category="小说" edition="2"><id>3</id><name>红楼梦</name><price>35</price><author>曹雪芹</author><detail><pressTime>清朝</pressTime><storyTime>不详</storyTime></detail></book><book category="神话小说" edition="4"><id>4</id><name>西游记</name><price>25</price><author>吴承恩</author><detail><pressTime>明朝</pressTime><storyTime>大唐</storyTime></detail></book><book category="小说" edition="5"><id>5</id><name>水浒传</name><price>30</price><author>施耐庵</author><detail><pressTime>明朝</pressTime><storyTime>大宋</storyTime></detail></book>
</books>

1.把所有的edition属性的值为8的修改为100
使用xpath查找对象时,依赖于jaxen.jar包,所以要先下载这个包。查找对象时,如果查找的是节点,直接写名称,如:/books/book/name,如果查找的是属性,要在属性前加上@,如:/books/book/@edition

    @Testpublic void modifyXmlFile(){try {SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));//先利用xpath查找对象List<Node> ns = document.selectNodes("/books/book/@edition");Iterator<Node> iter = ns.iterator();while(iter.hasNext()){Attribute attr = (Attribute) iter.next();if(Integer.parseInt(attr.getValue())==8){attr.setValue("100");}}//输出修改后的文件PrintWriter out = new PrintWriter(new File("F:\\test\\m1.xml"));XMLWriter w = new XMLWriter(out,OutputFormat.createPrettyPrint());w.write(document);w.close();} catch (DocumentException e) {e.printStackTrace();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} }

2.把“Java编程思想”修改为“Java语言程序设计”并在该name属性所在的book节点中添加buyTime节点,节点值为2015-04-27:

    @Testpublic void modifyXmlFile(){try {SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));//先利用xpath查找对象List<Node> ns = document.selectNodes("/books/book/name");Iterator<Node> iter = ns.iterator();while(iter.hasNext()){Element e = (Element) iter.next();if(e.getText().equals("Java编程思想")){e.setText("Java语言程序设计");Element pe = e.getParent();Element new_e = pe.addElement("buyTime");new_e.setText("2015-04-27");}}//输出修改后的文件PrintWriter out = new PrintWriter(new File("F:\\test\\m2.xml"));XMLWriter w = new XMLWriter(out,OutputFormat.createPrettyPrint());w.write(document);w.close();} catch (DocumentException e) {e.printStackTrace();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} }

3.若edition属性值为8,则删除该属性

    @Testpublic void modifyXmlFile(){try {SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));List<Node> ns = document.selectNodes("/books/book/@edition");Iterator<Node> iter = ns.iterator();while(iter.hasNext()){Attribute attr = (Attribute) iter.next();if(Integer.parseInt(attr.getValue())==8){attr.getParent().remove(attr);}}try {PrintWriter out = new PrintWriter(new File("F:\\test\\m3.xml"));XMLWriter w = new XMLWriter(out,OutputFormat.createPrettyPrint());w.write(document);w.close();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}} catch (DocumentException e) {e.printStackTrace();}}

4.把id为3的书的name节点删除:

@Test
public void modifyXmlFile(){try {SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));List<Node> ns = document.selectNodes("/books/book/id");Iterator<Node> iter = ns.iterator();while(iter.hasNext()){Element e = (Element) iter.next();if(e.getText().equals("3")){e.getParent().remove(e.getParent().element("name"));}}PrintWriter out = new PrintWriter(new File("F:\\test\\m4.xml"));XMLWriter w = new XMLWriter(out, OutputFormat.createPrettyPrint());w.write(document);w.close();} catch (DocumentException e) {e.printStackTrace();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}

5.移除所有文件的id属性:

方式一:
直接查找id节点,再删除

    @Testpublic void modifyXmlFile(){try {SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));List<Node> ns = document.selectNodes("/books/book/id");Iterator<Node> iter = ns.iterator();while(iter.hasNext()){Element e = (Element) iter.next();e.getParent().remove(e);}PrintWriter out = new PrintWriter(new File("F:\\test\\m5.xml"));XMLWriter w = new XMLWriter(out,OutputFormat.createPrettyPrint());w.write(document);w.close();} catch (DocumentException e) {e.printStackTrace();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}

方法二:
查找book节点,再删除book节点的id节点:

    @Testpublic void modifyXmlFile(){try {SAXReader reader = new SAXReader();Document document = reader.read(new File("F:\\test\\books.xml"));List<Node> ns = document.selectNodes("/books/book");Iterator<Node> iter = ns.iterator();while(iter.hasNext()){Element e = (Element) iter.next();e.remove(e.element("id"));}PrintWriter out = new PrintWriter(new File("F:\\test\\m6.xml"));XMLWriter w = new XMLWriter(out,OutputFormat.createPrettyPrint());w.write(document);w.close();} catch (DocumentException e) {e.printStackTrace();} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}

好了,先写这么多,这些东东基本上够项目使用了。

转载于:https://www.cnblogs.com/qitian1/p/6461875.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/273291.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

交叉连接(CROSS JOIN)的实际应用

一次偶然的机会&#xff0c;使用到了万年不用的交叉连接&#xff08;CROSS JOIN&#xff09; 业务场景如下&#xff1a; 1、存在多个运营商&#xff0c;每个运营商下面都有各种类型的设备&#xff0c;不同运营商的设备不完全相同&#xff1b; 2、任何设备有且仅有两种用途‘…

C# xml文件读取与修改

c#读写xml文件已知有一个XML文件&#xff08;bookstore.xml&#xff09;如下&#xff1a; Code<?xml version"1.0" encoding"gb2312"?><bookstore> <book genre"fantasy" ISBN"2-3631-4"> <title>Obero…

外连接从表过滤

1、使用left join时从表的过滤 WITH a AS( SELECT A aid FROM dual UNION ALL SELECT B FROM dual UNION ALL SELECT C FROM dual UNION ALL SELECT D FROM dual UNION ALL SELECT E FROM dual ), b AS( SELECT A aid,10 num,1 type FROM dual UNION ALL SELECT B,20,2 FROM d…

ORACLE将查询字段指定为某种类型

SELECT CAST(张三 AS VARCHAR2(20)) name FROM dual; 一般来说在查询时很少有用到这种语句&#xff0c;但是使用CREATE TABLE ... AS SELECT ...语句的时候这个就很好用了 --建表 CREATE TABLE test01 AS SELECT 张三 name FROM dual; --正常插入数据 INSERT INTO test01 SEL…

分组查询最晚一条数据(ORACLE)

现有客户表&#xff0c;交费表&#xff0c;需查询每个存在交费记录客户的最后一笔交费信息 这里提供两种方式 注&#xff1a;客户不会在同一时间有两条交费&#xff0c;SQL可直接执行 --查询客户名称&#xff0c;最后一笔交费时间&#xff0c;以及最后一笔交费金额 WITH --客…

ORACLE循环中使用序列

在批量生成数据时&#xff0c;经常会用到序列的Nextval&#xff0c;今天碰到了这样的情况&#xff0c;日常记录&#xff0c;下附解决方案。先看这段脚本 DECLARE i INTEGER; BEGINFOR cur IN 1..5 LOOPi : DomainObjectId.Nextval;dbms_output.put_line(i);END LOOP; END; 编…

mysql001创建数据库

-- 注释&#xff0c;ctrl/ -- 查询所有数据库&#xff1b; show DATABASES; -- 创建数据库; CREATE DATABASE studb; -- 切换数据库; USE studb; -- 删除数据库 DROP DATABASE studb;

mysql002创建表

-- 创建student表 DDL CREATE TABLE stdent( sno int(3), name VARCHAR(55), sex CHAR(2), age int, dtdate date, classname VARCHAR(55), email VARCHAR(55) ) -- 查询表中数据 DQL SELECT * FROM stdent;

mysql003操作表DDL

-- 查询表中数据 DQL 注意在mydb数据库下面 SELECT * FROM stdent; -- 在表中添加一列 DDL -- 新增列 默认添加到最后 ALTER TABLE stdent add score DOUBLE(4,1); -- 新增一列 在表中开头添加 ALTER TABLE stdent add score2 double(5,1) first; -- 在指定列后面添…

mysql005约束.列级别

-- 列级约束 -- sno 主键&#xff1a;唯一&#xff0c;不为空&#xff0c;自增 -- name 非空 -- sex 非空&#xff0c;默认值&#xff0c;只有男女 -- age 0-30岁 -- score 非空 -- dtdate 非空 -- classname 非空 -- email唯一 -- 创建表&#xff0c;增加列级约束 …

hdu.1430.魔板(bfs + 康托展开)

魔板 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2170 Accepted Submission(s): 455 Problem Description在魔方风靡全球之后不久&#xff0c;Rubik先生发明了它的简化版——魔板。魔板由8个同样大小的方…

mysql006添加外键约束

-- 添加外键 -- 建立主表&#xff0c;班级表 CREATE TABLE class( cno int PRIMARY key auto_increment, cname VARCHAR(55) ) SELECT * FROM class; -- 建立从表&#xff0c;学生表 CREATE table stu( sno int PRIMARY KEY auto_increment, sname VARCHAR(55), sex ch…

Circle-Progress-View

https://github.com/jakob-grabner/Circle-Progress-View 转载于:https://www.cnblogs.com/eustoma/p/4507476.html

elasticsearch 删除满足条件的语句_ELK从入门到还未精通(二)——ElasticSearch上篇

大家好&#xff0c;我是泥腿子安尼特&#xff0c;5个月没在李佬都公众号更新文章了。上一篇&#xff0c;大致介绍了作为工具人的我是如何基本使用这一套ELK 系统的。今天就讲讲这个最重要的E——基于Lucene的搜索引擎ElasticSearch(后面简称ES)。最近刚搬家&#xff0c;没想到隔…

mysql004操作表.增删改

-- 查询表中数据 DQL 注意在mydb数据库下面 SELECT * FROM stdent; -- 新增数据 这种写法数据的循序和数据库的字段循序保持一致。 INSERT INTO stdent values (1,"张三","男",25,"2021.1.1","java","123qq.com"); --…

纸板怎么切割光滑_激光切割机大PK!光纤、CO2、YAG,你选谁?!

问&#xff1a;我也是钣金人&#xff0c;怎么加入组织&#xff1f;答&#xff1a;点标题下方蓝字“钣金家园光纤激光切割机之所以能在市场快速站稳脚跟并且逐步替代传统切割工艺&#xff0c;是由于其在各方面独具优势&#xff0c;那么他到底优秀在哪里呢&#xff1f;我们把CO2激…

mysql007.算数运算.别名.去重.排序

-- 创建DEPT表 CREATE TABLE DEPT( DEPTNO int(2) not null, DNAME VARCHAR(14), LOC VARCHAR(13) ); -- 查询DEPT表 SELECT * FROM DEPT; -- 修改表&#xff0c;添加主键 ALTER TABLE DEPT add CONSTRAINT PK_DEPT PRIMARY KEY(DEPTNO); -- 查询表结构。 desc DEPT; …

c# 蓝牙虚拟串口_蓝牙模块——基础知识介绍

1. 数据透传蓝牙模块可以通过串口(SPI、IIC)和MCU控制设备进行数据传输。蓝牙模块可以做为主机和从机。主机就是能够搜索别的蓝牙模块并主动建立连接&#xff0c;从机则不能主动建立连接&#xff0c;只能等别人连接自己。2. 低功耗低功耗蓝牙(Bluetooth Low Energy)&#xff0c…

Error: could not open `C:\Java\jre7\lib\i386\jvm.cfg

打开eclipse时出现Error: could not open C:\Program Files\Java\jre7\lib\i586\jvm.cfg’) 删除 c:\windows\system32\java&#xff0c; c:\windows\system32\javaw&#xff0c; c:\windows\system32\javaws, 如果是64位系统&#xff0c;还要删除 c:\windows\SysWOW64\java&am…

java项目001.双色球游戏

package Suangseq; //双色球游戏制作。 import java.awt.SystemColor; import java.util.Arrays; import java.util.Scanner; public class TextA { public static void main(String[] args) { boolean flagfalse;//定义一个布尔类型的变量。 int[] mynull;//定义一个变量 in…