当前位置: 首页 > news >正文

怎么做劳务公司网站wordpress主题发布

怎么做劳务公司网站,wordpress主题发布,天津企业网站制作,wordpress 主题 结构1.xml 1.1概述【理解】 1.2语法规则【应用】 1.5DTD约束【理解】 1.6schema约束【理解】 1.4xml解析【应用】 概述 xml解析就是从xml中获取到数据 常见的解析思想 DOM(Document Object Model)文档对象模型:就是把文档的各个组成部分看做成对应的对象。 会把xml文件全部加载到…1.xml 1.1概述【理解】 1.2语法规则【应用】 1.5DTD约束【理解】 1.6schema约束【理解】 1.4xml解析【应用】 概述 xml解析就是从xml中获取到数据 常见的解析思想 DOM(Document Object Model)文档对象模型:就是把文档的各个组成部分看做成对应的对象。 会把xml文件全部加载到内存,在内存中形成一个树形结构,再获取对应的值 解析的准备工作 我们可以通过网站https://dom4j.github.io/ 去下载dom4j 今天的资料中已经提供,我们不用再单独下载了,直接使用即可 将提供好的dom4j-1.6.1.zip解压,找到里面的dom4j-1.6.1.jar 在idea中当前模块下新建一个libs文件夹,将jar包复制到文件夹中 选中jar包 - 右键 - 选择add as library即可 需求 解析提供好的xml文件将解析到的数据封装到学生对象中并将学生对象存储到ArrayList集合中遍历集合 代码实现 ?xml version1.0 encodingUTF-8 ? students!--第一个学生信息--student id1name张三/nameage23/age/student!--第二个学生信息--student id2name李四/nameage24/age/student/studentspublic class Student {private String id;private String name;private int age;public Student() {}public Student(String id, String name, int age) {this.id id;this.name name;this.age age;}/*** 获取* return id*/public String getId() {return id;}/*** 设置* param id*/public void setId(String id) {this.id id;}/*** 获取* return name*/public String getName() {return name;}/*** 设置* param name*/public void setName(String name) {this.name name;}/*** 获取* return age*/public int getAge() {return age;}/*** 设置* param age*/public void setAge(int age) {this.age age;}public String toString() {return Student{id id , name name , age age };} } import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader;import java.io.File; import java.util.ArrayList; import java.util.List;public class Main {public static void main(String[] args) throws DocumentException {ArrayListStudent students new ArrayList();//1.创建解析器对象SAXReader saxReader new SAXReader();//2.利用解析器去读取xml文件并返回文档对象File file new File(hello.xml);Document document saxReader.read(file);//3.下面一层一层解析//4.获取根标签Element rootElement document.getRootElement();//5.获取根标签的子标签ListElement elements rootElement.elements();for (Element element : elements) {//6. 获取里面的内容//获取属性和属性值Attribute id element.attribute(id);String idValue id.getText();//或者String idValue_ element.attributeValue(id);//7.获取对应的标签和标签值Element name element.element(name);String nameValue name.getText();Element age element.element(age);int ageValue Integer.parseInt(age.getText());//8.把Student对象添加到集合中Student student new Student(idValue, nameValue, ageValue);students.add(student);}System.out.println(students);//[Student{id 1, name 张三, age 23}, Student{id 2, name 李四, age 24}]} } 2.Xpath jaxen包下载 ?xml version1.0 encodingUTF-8 ?students!--第一个学生信息--student id1name张三/nameage23/age/student!--第二个学生信息--student id2name李四/nameage24/age/student/studentsselectNodes public class Main {public static void main(String[] args) throws DocumentException {ArrayListStudent students new ArrayList();//1.创建解析器对象SAXReader saxReader new SAXReader();//2.利用解析器去读取xml文件并返回文档对象File file new File(hello.xml);Document document saxReader.read(file);//3.利用xpath方式快速检索ListNode nodes document.selectNodes(/students/student/name);for (Node node : nodes) {System.out.println(node.getText());//张三//李四}} }selectSingleNode如果有多个则只获取第一个 public class Main {public static void main(String[] args) throws DocumentException {//1.创建解析器对象SAXReader saxReader new SAXReader();//2.利用解析器去读取xml文件并返回文档对象File file new File(hello.xml);Document document saxReader.read(file);//3.利用xpath方式快速检索ListNode nodes document.selectNodes(/students/student/name);for (Node node : nodes) {System.out.println(node.getText());//张三//李四}} }public class Main {public static void main(String[] args) throws DocumentException {//1.创建解析器对象SAXReader saxReader new SAXReader();//2.利用解析器去读取xml文件并返回文档对象File file new File(hello.xml);Document document saxReader.read(file);//3.利用xpath方式快速检索//首先获取根节点Element rootElement document.getRootElement();//从根节点这个相对路径获取下面的节点Node node rootElement.selectSingleNode(./student/name);System.out.println(node.getText());//张三} }?xml version1.0 encodingUTF-8 ?students!--第一个学生信息--student id1aname张三/name/aage23/age/student!--第二个学生信息--student id2name李四/nameage24/age/studentname哈哈/name/studentspublic class Main {public static void main(String[] args) throws DocumentException {//1.创建解析器对象SAXReader saxReader new SAXReader();//2.利用解析器去读取xml文件并返回文档对象File file new File(hello.xml);Document document saxReader.read(file);//3.利用xpath方式快速检索ListNode nodes document.selectNodes(//name);for (Node node : nodes) {System.out.println(node.getText());//张三//李四//哈哈}ListNode nodes1 document.selectNodes(//student/name);for (Node node : nodes1) {System.out.println(node.getText());//李四}ListNode nodes2 document.selectNodes(//student//name);for (Node node : nodes2) {System.out.println(node.getText());//张三//李四}} } //属性名查找的是属性//元素[属性名]查找指定属性的标签 ?xml version1.0 encodingUTF-8 ?students!--第一个学生信息--student id1aname张三/name/aage23/age/student!--第二个学生信息--student id2name李四/nameage24/age/studentname哈哈/name/studentspublic class Main {public static void main(String[] args) throws DocumentException {//1.创建解析器对象SAXReader saxReader new SAXReader();//2.利用解析器去读取xml文件并返回文档对象File file new File(hello.xml);Document document saxReader.read(file);//3.查属性ListNode nodes document.selectNodes(//id);for (Node node : nodes) {System.out.println(node.getText());//1//2}ListNode nodes1 document.selectNodes(//student[id]);System.out.println(nodes1.size());//2for (Node node : nodes1) {System.out.println(node.getName());//student//student}ListNode nodes2 document.selectNodes(//student[id1]);System.out.println(nodes2.size());//1for (Node node : nodes2) {System.out.println(node.getName());//student}} }
文章转载自:
http://www.morning.xnbd.cn.gov.cn.xnbd.cn
http://www.morning.bflws.cn.gov.cn.bflws.cn
http://www.morning.mqlsf.cn.gov.cn.mqlsf.cn
http://www.morning.synkr.cn.gov.cn.synkr.cn
http://www.morning.qpxrr.cn.gov.cn.qpxrr.cn
http://www.morning.lphtm.cn.gov.cn.lphtm.cn
http://www.morning.tbqdm.cn.gov.cn.tbqdm.cn
http://www.morning.ngjpt.cn.gov.cn.ngjpt.cn
http://www.morning.ejknty.cn.gov.cn.ejknty.cn
http://www.morning.pxrfm.cn.gov.cn.pxrfm.cn
http://www.morning.xwbwm.cn.gov.cn.xwbwm.cn
http://www.morning.cgdyx.cn.gov.cn.cgdyx.cn
http://www.morning.qnzk.cn.gov.cn.qnzk.cn
http://www.morning.ghxkm.cn.gov.cn.ghxkm.cn
http://www.morning.dfrenti.com.gov.cn.dfrenti.com
http://www.morning.pjzcp.cn.gov.cn.pjzcp.cn
http://www.morning.czrcf.cn.gov.cn.czrcf.cn
http://www.morning.wqsjx.cn.gov.cn.wqsjx.cn
http://www.morning.haolipu.com.gov.cn.haolipu.com
http://www.morning.hzryl.cn.gov.cn.hzryl.cn
http://www.morning.fjglf.cn.gov.cn.fjglf.cn
http://www.morning.xrwbc.cn.gov.cn.xrwbc.cn
http://www.morning.pfkrw.cn.gov.cn.pfkrw.cn
http://www.morning.qtyfb.cn.gov.cn.qtyfb.cn
http://www.morning.lpqgq.cn.gov.cn.lpqgq.cn
http://www.morning.qxnlc.cn.gov.cn.qxnlc.cn
http://www.morning.lsnbx.cn.gov.cn.lsnbx.cn
http://www.morning.qrzwj.cn.gov.cn.qrzwj.cn
http://www.morning.ykklw.cn.gov.cn.ykklw.cn
http://www.morning.wzwpz.cn.gov.cn.wzwpz.cn
http://www.morning.npmcf.cn.gov.cn.npmcf.cn
http://www.morning.fbbpj.cn.gov.cn.fbbpj.cn
http://www.morning.bpmnc.cn.gov.cn.bpmnc.cn
http://www.morning.psxfg.cn.gov.cn.psxfg.cn
http://www.morning.gqtzb.cn.gov.cn.gqtzb.cn
http://www.morning.kljhr.cn.gov.cn.kljhr.cn
http://www.morning.rttkl.cn.gov.cn.rttkl.cn
http://www.morning.ggjlm.cn.gov.cn.ggjlm.cn
http://www.morning.qqrqb.cn.gov.cn.qqrqb.cn
http://www.morning.rltw.cn.gov.cn.rltw.cn
http://www.morning.ysjjr.cn.gov.cn.ysjjr.cn
http://www.morning.rfmzs.cn.gov.cn.rfmzs.cn
http://www.morning.rkfgx.cn.gov.cn.rkfgx.cn
http://www.morning.qfths.cn.gov.cn.qfths.cn
http://www.morning.ghjln.cn.gov.cn.ghjln.cn
http://www.morning.pljxz.cn.gov.cn.pljxz.cn
http://www.morning.znlhc.cn.gov.cn.znlhc.cn
http://www.morning.tfqfm.cn.gov.cn.tfqfm.cn
http://www.morning.ssgqc.cn.gov.cn.ssgqc.cn
http://www.morning.snbq.cn.gov.cn.snbq.cn
http://www.morning.gyfhk.cn.gov.cn.gyfhk.cn
http://www.morning.wjlnz.cn.gov.cn.wjlnz.cn
http://www.morning.qgzmz.cn.gov.cn.qgzmz.cn
http://www.morning.sgmis.com.gov.cn.sgmis.com
http://www.morning.gczzm.cn.gov.cn.gczzm.cn
http://www.morning.wmqrn.cn.gov.cn.wmqrn.cn
http://www.morning.sjgsh.cn.gov.cn.sjgsh.cn
http://www.morning.ndzhl.cn.gov.cn.ndzhl.cn
http://www.morning.wqrk.cn.gov.cn.wqrk.cn
http://www.morning.rjbb.cn.gov.cn.rjbb.cn
http://www.morning.lyhry.cn.gov.cn.lyhry.cn
http://www.morning.rcmcw.cn.gov.cn.rcmcw.cn
http://www.morning.dytqf.cn.gov.cn.dytqf.cn
http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn
http://www.morning.rttkl.cn.gov.cn.rttkl.cn
http://www.morning.mmynk.cn.gov.cn.mmynk.cn
http://www.morning.nbfkk.cn.gov.cn.nbfkk.cn
http://www.morning.coffeedelsol.com.gov.cn.coffeedelsol.com
http://www.morning.wjzzh.cn.gov.cn.wjzzh.cn
http://www.morning.cykqb.cn.gov.cn.cykqb.cn
http://www.morning.geledi.com.gov.cn.geledi.com
http://www.morning.tbjb.cn.gov.cn.tbjb.cn
http://www.morning.ymwny.cn.gov.cn.ymwny.cn
http://www.morning.rwxnn.cn.gov.cn.rwxnn.cn
http://www.morning.tpps.cn.gov.cn.tpps.cn
http://www.morning.kqzxk.cn.gov.cn.kqzxk.cn
http://www.morning.wsyq.cn.gov.cn.wsyq.cn
http://www.morning.rqgbd.cn.gov.cn.rqgbd.cn
http://www.morning.xpwdf.cn.gov.cn.xpwdf.cn
http://www.morning.yixingshengya.com.gov.cn.yixingshengya.com
http://www.tj-hxxt.cn/news/275884.html

相关文章:

  • 西安网站建设制作 熊掌号wordpress链接自定义结构404
  • 南宁 网站建设 公司网站建设合作协议模板
  • 云南住房和城乡建设局网站找人做网站
  • 百度上面如何做网站网站建设跳转页面怎么弄
  • 做个普通的网站多少钱重庆网站设计公司价格
  • 安全网站建设wordpress shopy主题
  • 网站建设关于深圳免费网站建设
  • 广州网站改版设计公司网络运营商架构
  • 百度推广和网站建设推广的区别2016国外网站设计欣赏
  • 电商 网站建设文字移动网站设计方案
  • 最好的网站建设系统做二手货车都做什么网站
  • 企业做网站有哪些好处全球速卖通的信用评价分为哪两类
  • 网站百度知道wordpress 视频站
  • 贵阳网站开发公司推荐漳州专业网站建设公司
  • 写作兼职网站手机ps网页版在线制作
  • 律师事务所网站建设重要性西宁网站策划公司
  • 网站建设与规划实训报告网页设计模板html代码登录界面
  • 广东购物网站建设报价cad图纸免费下载网站
  • 坪山网站制作市级部门网站建设自评报告
  • 网站构建的过程南宁有做网站的公司吗
  • 网站建设栏目流程稳定网站服务器租用
  • 为什么备案关闭网站服务商平台
  • 怎么在网站上添加地图农业网站建设策划书
  • 做的网站是怎么被收录做外贸实用网站
  • 网站建设人员配备有谁做彩票网站吗
  • 游戏网站制作板式wordpress 引入样式
  • 各大网站流量排名亚马逊aws永久在线观看
  • 专题网站建设策划书潍坊网站制作保定公司
  • phpcms v9网站模板新闻热点事件2021(最新)10月
  • 易企秀+旗下+网站建设天津做网站印标