XML读取
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class XMLReader {
public static List<File> fileList = null;
public static List<String> startWidth = null;
public static void main(String[] args) throws Exception {
File root = new File("xml");
File[] files = root.listFiles();
fileList = Arrays.asList(files);
SAXReader reader = new SAXReader();
for (File file : fileList) {
Document document = reader.read(file);
startTest(document, file);
}
System.out.println("------------ end ------------");
}
public static void startTest(Document document, File file) {
if (!startWithSE(document, file))
return;
if (!isN(document, file))
return;
if (!isNGBOrTenNumber(document, file))
return;
if (!startWithNGBS(document, file))
return;
if (!hasNode(document, file))
return;
if (!notZero(document, file))
return;
}
/*
* /FMS/SEA_OBL/JOB_NO 以SE开始
*
*/
public static boolean startWithSE(Document document, File file) {
String path = "/FMS/SEA_OBL/JOB_NO";
List list1 = document.selectNodes(path);
String text = null;
for (Element tel : (List<Element>) list1) {
text = tel.getTextTrim();
if (!text.startsWith("SE")) {
// fileList.remove(file);
System.out.println(file.getName() + " " + path
+ " not startWithSE");
copyFiles( file);
return false;
}
}
return true;
}
// /FMS/SEA_OBL/NORMAL_DIRECT 为N
public static boolean isN(Document document, File file) {
String path = "/FMS/SEA_OBL/NORMAL_DIRECT";
List list1 = document.selectNodes(path);
String text = null;
for (Element tel : (List<Element>) list1) {
text = tel.getTextTrim();
if (!text.equals("N")) {
// fileList.remove(file);
S
相关文档:
使用Metadata简化表数据向XML形式转化的实现
如果需要将表数据转化为XML形式数据的话,如果我们使用Spring的JDBC Template,那么常需要做的工作是创建一个RowMapper匿名类,在其中将字段与领域对象的某个属性匹配上,然后得到领域对象链表形式的结果,此后展开这个集合,再将字段转化为XML数据,其中进行了两次名称和值之 ......
同步程序案例
procedure TGetOrderThread.PostDB(webnr:WideString);
var
Err: String;
SetWebnr:WideString;
xmlDoc: IXMLDocument;
root: IXMLNode;
rowc: IXMLNode;//记录数
rows: IXMLNodeList;//主记录列表
row: IXMLNode;
drows: IXMLNodeList;// ......
快逸报表有着强大的输出功能,可以直接把web报表导出为Excel、Word、Pdf、Txt等文件形式。但是一些web报表用户希望可以将报表导出到XML文件中以便对数据进行分析与解析,这样就需要我们用一些特殊的方法去实现了。
实现思路
:导出XML功能的可以通过将计算好的IReport对象传递给快逸提供的com.runqian.report4.view.xml ......
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.org/config/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/bea ......
首先下载JDOM.JAR加入的classpath中
package com.test.search;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
public class ToXML {
public ......