package com.huayingsoft.util;
import java.io.File;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
public class XMLHelper {
private Document doc;
public XMLHelper() {
}
/**
* 判断文件扩展名
*
* @param fileNameStr
* 文件名
* @param extendName
* 扩展名
*/
public boolean estimateExtend(String fileNameStr, String extendName) {
int pos = fileNameStr.trim().lastIndexOf(".");
if (pos == -1 || pos == 0 || pos == fileNameStr.trim().length() - 1)
return false;
String extendStr = fileNameStr.trim().substring(pos + 1);
if (extendStr.equalsIgnoreCase(extendName))
return true;
else
return false;
}
/**
* 更改文件扩展名
*
* @param fileNameStr
* 文件名
* @param extendName
* 扩展名
*/
private String changeExtend(String fileNameStr, String extendName) {
int pos = fileNameStr.trim().lastIndexOf(".");
if (pos == -1 || pos == 0)
return fileNameStr;
fileNameStr = fileNameStr.trim().substring(0, pos + 1) + extendName;
return fileNameStr;
}
public String readXmlThreeLayer(String xmlFile, String Xpath,
boolean hasAttr, String[] attrNames) throws Exception {
try {
StringBuilder sb = new StringBuilder();
File f = new File(xmlFile);
if (f.exists()) {
// XmlNodeList list = null;
NodeList list = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
this.doc = db.parse(f);
String attr = "";
// this.doc = new XmlDocument();
// this.doc.Load(xmlFile);
if (Xpath != null || Xpath.length() > 0) {
XPath xpath = XPathFactory.newInstance().newXPath();
list = (NodeList) xpath.evaluate(Xpath, this.doc,
XPathConstants.NODESET);
// list = this.doc.SelectSingleNode(Xpath).ChildNodes;
} else {
list = this.doc.getDocumentElement().getChildNodes();
}
int lengthTop = list.getLength();
for (int i = 0; i < lengthTop; i++) {
int lengthTwo = list.item(i).getChildNodes().getLength();
for (int j = 0; j < lengthTwo; j++) {
int lengthThree = list.item(i).getChildNodes().item(j)
.getChildNodes().getLength();
if (lengthThree > 1) {
for (int k = 0; k < lengthThree; k++) {
String node = list.item(i).getChildNodes()
.item(j).getChildNodes().item(k)
.getNodeValue();
if (hasAttr)
attr = this.readAttribute(list.item(i)
.getChildNodes().item(j)
.getChildNodes().item(k)
.getAttributes(), attrNames);
if (k != lengthThree - 1) {
// sb.AppendFormat("{0}{1}$", node, attr);
sb.append(node + attr + "$");
} else {
// sb.AppendFormat("{0}{1}", node, attr);
sb.append(node + attr);
}
}
} else if (lengthThree == 1) {
// sb.AppendFormat("{0}",
// list.Item(i).ChildNodes.Item(j).ChildNodes.Item(0).InnerText);
sb.append(list.item(i).getChildNodes().item(j)
.getChildNodes().item(0).getNodeValue());
} else {
// sb.AppendFormat("{0}", list.Item(i).InnerText);
sb.append(list.item(i).getNodeValue());
}
if (hasAttr)
attr = this.readAttribute(list.item(i)
.getChildNodes().item(j).getAttributes(),
attrNames);
if (j != lengthTwo - 1) {
// sb.AppendFormat("{0}#", attr);
sb.append(attr + "#");
} else {
// sb.AppendFormat("{0}", attr);
sb.append(attr);
}
}
if (hasAttr)
attr = this.readAttribute(list.item(i).getAttributes(),
attrNames);
// sb.AppendFormat("{0}|", attr);
sb.append(attr + "|");
}
} else
sb.append("--文件不存在!--");
return sb.toString();
} catch (Exception e) {
throw e;
}
}
public String readXmlThreeLayer(String xmlFile, boolean hasAttr,
String[] attrNames) {
try {
return this.readXmlThreeLayer(xmlFile, "", hasAttr, attrNames);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public String readXml(String xmlFile, String pNodePath, String[] nodeNames,
boolean hasAttr, String[] attrNames) throws Exception {
StringBuilder sb = new StringBuilder();
File f = new File(xmlFile);
try {
if (f.exists()) {
Node root = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
this.doc = db.parse(f);
// this.doc = new XmlDocument();
// this.doc.Load(xmlFile);
if (pNodePath != null && pNodePath.length() > 0) {
XPath xpath = XPathFactory.newInstance().newXPath();
root = (Node) xpath.evaluate(pNodePath, this.doc,
XPathConstants.NODE);
// root = this.doc.SelectSingleNode(pNodePath);
} else
root = this.doc.getDocumentElement();
if (root != null) {
if (root.hasChildNodes()) {
// sb.AppendFormat("{0}",
// this.readChildNode(root.ChildNodes, nodeNames,
// hasAttr, attrNames));
sb.append(this.readChildNode(root.getChildNodes(),
nodeNames, hasAttr, attrNames));
} else {
// sb.AppendFormat("{0}",root.InnerText);
sb.append(root.getNodeValue());
}
} else
sb.append("--节点不存在--");
} else
sb.append("--文件不存在!--");
} catch (Exception e) {
throw e;
}
return sb.toString();
}
public String readXml(String xmlFile, String pNodePath, String[] nodeNames,
boolean hasAttr) {
try {
return this.readXml(xmlFile, pNodePath, nodeNames, hasAttr, null);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public String readXml(String xmlFile, String pNodePath, boolean hasAttr)
throws Exception {
StringBuilder sb = new StringBuilder();
File f = new File(xmlFile);
try {
if (f.exists()) {
NodeList root = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory
.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
this.doc = db.parse(f);
// this.doc=new XmlDocument();
// this.doc.Load(xmlFile);
if (pNodePath != null && !pNodePath.equals("")) {
if (!pNodePath.trim().equals("%")) {
// sb.AppendFormat("{0}",this.readXml(xmlFile,pNodePath,null,false,null));
XPath xpath = XPathFactory.newInstance().newXPath();
// XmlNode node=this.doc.SelectSingleNode(pNodePath);
Node node = (Node) xpath.evaluate(pNodePath, this.doc,
XPathConstants.NODE);
if (node != null) {
if (node.hasChildNodes()) {
root = node.getChildNodes();
int len = root.getLength();
for (int p = 0; p < len; p++) {
if (root.item(p).hasChildNodes()) {
int tmp = root.item(p).getChildNodes()
.getLength();
for (int k = 0; k < tmp; k++) {
if (k == tmp - 1) {
String attr1 = "";
if (hasAttr)
attr1 = this
.readAttribute(root
.item(p)
.getAttributes());
// sb.AppendFormat("{0}{1}|",root.Item(p).ChildNodes.Item(k).InnerText,attr1);
sb.append(root.item(p)
.getChildN
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
数据库使用mysql5,jdk5,6,7以上,eclipse indigo 3.7.2其他没有什么要求,数据库访问地址配置:数据库连接配置文件:HuayingsoftDataBaseConfig.properties,只需要配置mysql部分的连接即可,HuayingsoftFrameworkConfig.xml模块访问配置,如果是本机可以不用改,如果是部署到服务器就改为对应域名就可以,系统管理员登录账号:webmaster 密码:sa,访问路径: http://127.0.0.1:8080/ClothingShopWeb/
资源推荐
资源详情
资源评论
收起资源包目录
JAVA服装进销存系统完整源码 支持会员卡预存充值 采购管理 销售管理 (1239个子文件)
lineb_s.bmp 1KB
lineb_f.bmp 1KB
line_f.bmp 1KB
line_s.bmp 1KB
line_e.bmp 1KB
lineb_x.bmp 990B
line_x.bmp 990B
line_y.bmp 614B
lineb_y.bmp 614B
XMLHelper.class 20KB
StringUtil.class 19KB
OracleDataAccess.class 19KB
MysqlDataAccess.class 19KB
ClothingSaleDAO.class 16KB
MSSqlDataAccess.class 14KB
ClothingStockInDAO.class 13KB
UserInfoDAO.class 13KB
DES.class 11KB
SaleBillManageDAO.class 11KB
YXRoleDAO.class 11KB
UserInfoDAO.class 9KB
StockBackDAO.class 9KB
CheckCountDAO.class 9KB
DBConnectionManager.class 9KB
MemberLevelSetDAO.class 9KB
SaleBackDAO.class 8KB
UserLoginBean.class 8KB
LunarCalendar.class 8KB
CheckCountDetailByKindDAO.class 8KB
CommonUtil.class 8KB
MD5.class 8KB
DataTableImpl.class 7KB
FileHelper.class 7KB
CheckCountDetailByGoodDAO.class 7KB
RequestUtils.class 7KB
DateUtil.class 7KB
ReportStockInDAO.class 7KB
DroplistUtil.class 7KB
ReportStockDAO.class 7KB
RoleUserDAO.class 7KB
ClothingBaseInfoDAO.class 7KB
MemberInfoDAO.class 7KB
DataTableTag.class 7KB
InitPwdAction.class 6KB
SaleBillManageService.class 6KB
FiresWorkInfoForm.class 6KB
DataBookDetailDAO.class 6KB
RoleDAO.class 6KB
ReportSaleDAO.class 6KB
LimitUserDAO.class 6KB
SetMenuDAO.class 6KB
DataColumnDAO.class 5KB
UserInfoService.class 5KB
LimitTimeDAO.class 5KB
DropListDao.class 5KB
Validate.class 5KB
StockInBillManageDAO.class 5KB
Base64.class 5KB
BaseDAO.class 5KB
ClothingKindInfoDAO.class 5KB
LimitIpDAO.class 5KB
CDDWRoleDAO.class 5KB
XQRoleDAO.class 5KB
StockInfoDAO.class 5KB
VelocityServlet.class 5KB
DroplistData.class 5KB
DataTableForm.class 5KB
RoleMenuDAO.class 5KB
DefineManagerDAO.class 4KB
EmployeeInfoDAO.class 4KB
SupplierInfoDAO.class 4KB
ShopInfoDAO.class 4KB
SystemConfig.class 4KB
OnLineMessageRandomImageServlet.class 4KB
RandomImageServlet.class 4KB
ClothingUnitSetDAO.class 4KB
ColorSetDAO.class 4KB
SizeSetDAO.class 4KB
Global.class 4KB
UserInfoAction.class 4KB
BrandSetDAO.class 4KB
RollMessageDAO.class 4KB
StockInBillManageService.class 4KB
TextCacheManager.class 4KB
DefineManagerService.class 4KB
DataTableDAO.class 4KB
SetHandleParameterFilter.class 4KB
LoginCheckDAO.class 4KB
LoginCheckService.class 4KB
ClothingSaleAction.class 4KB
LoginCheckFilter.class 4KB
AddDataBookDAO.class 4KB
Transform.class 4KB
MemberLevelSetAction.class 3KB
DataColumnForm.class 3KB
StockBackAction.class 3KB
RoleBean.class 3KB
SaleBackAction.class 3KB
LogUtil.class 3KB
UserInfoForm.class 3KB
共 1239 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
行动之上
- 粉丝: 2084
- 资源: 928
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功