xpath提取xml文档数据
来源:互联网 发布:淘宝晒单福利图 编辑:程序博客网 时间:2024/04/28 07:43
package cn.itcast.sax;
import java.io.File;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
public class Demo5 {
/**
* 查找user.xml文档是否有和用户相匹配的用户名和密码
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String username = "aaa";
String password = "123";
//检测xml文档是否有匹配的用户名和密码
SAXReader reader = new SAXReader();
Document document = reader.read(new File("src/user.xml"));
Node node = document.selectSingleNode("//user[@username='"+username+"' and @password='"+password+"']");
if(node==null){
System.out.println("用户名或密码错误");
}else{
System.out.println("登陆成功!!!");
}
}
}
import java.io.File;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
public class Demo5 {
/**
* 查找user.xml文档是否有和用户相匹配的用户名和密码
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String username = "aaa";
String password = "123";
//检测xml文档是否有匹配的用户名和密码
SAXReader reader = new SAXReader();
Document document = reader.read(new File("src/user.xml"));
Node node = document.selectSingleNode("//user[@username='"+username+"' and @password='"+password+"']");
if(node==null){
System.out.println("用户名或密码错误");
}else{
System.out.println("登陆成功!!!");
}
}
}
0 0
- XPath提取xml文档数据
- xpath提取xml文档数据
- xpath提取xml文档数据
- xpath提取xml文档数据
- XPath提取XML文档数据
- 使用XPath提取xml文档数据
- 使用Xpath查询xml文档节点数据
- 使用DOM4J解析XML文档,以及使用XPath提取XML文档
- XPath 文档 解析XMl
- xpath读取xml文档
- xpath解析xml文档
- 数据提取----httpclient,htmlparser,xpath
- 利用XPath解析XML文档
- ajax的核心技术应用--javascript 解析xml文档,提取xml文档中的数据
- xPath 动态分离XML数据
- XPath查询XML文档的注意事项
- 用XPath解析XML文档(一)
- 用XPath解析XML文档(二)
- 002
- C macros __LINE__, __FILE__ and __func__
- Cassandra源码学习:机架感应策略
- Win7上Git图形界面安装及配置过程
- android 图片Bitmap的旋转
- xpath提取xml文档数据
- hdoj 1429 胜利大逃亡(续) (BFS+位压缩判重)
- 使用crontab自动执行php文件
- Using XPath to identify Web objects from Selenium WebDriver
- 笔记16--控件遇到的问题汇总
- z-index在ie7下不起作用
- [随笔]VS的相对路径
- 卡方检验(Chi square statistic)
- Cassandra源码学习:数据模型