易截截图软件、单文件、免安装、纯绿色、仅160KB

读取xml指定节点值并生成csv文件

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class XmlReader {
/**
* 读取xml文件指定节点内容并导出到csv文件中
* @param path
* 指定文件夹路径
* @param destNode
* 目标节点
* @param fileName
* 出力csv文件名
*/
public void readXmlFile(String path, String destNode, String fileName) {
File file = new File(fileName);
FileOutputStream out;
try {
// 建立csv输出文件流
out = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(out);
BufferedWriter bw = new BufferedWriter(osw);
// 初始化csv文件
initCSV(bw);

// 得到指定文件夹下的所有xml文件
List fileList = getXmlFiles(path);
// 创建xml文件
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = null;
String xmlFileName;
Node root;
NodeList links;
for (int k = 0; k < fileList.size(); k++) {
xmlFileName = fileList.get(k).toString();
doc = builder.parse(xmlFileName);
doc.normalize();
// xml文件根节点
root = doc.getDocumentElement();
// xml文件中所有指定节点
links = doc.getElementsByTagName(destNode);
for (int i = 0; i < links.getLength(); i++) {
Node link = links.item(i);
// 指定节点的所有子节点
NodeList childNodes = link.getChildNodes();
StringBuffer sb = new StringBuffer();
// 遍历子节点
for (int j = 0; j < childNodes.getLength(); j++) {
Node chi


相关文档:

使用 PHP 处理 XML 配置文件


使用 PHP 处理 XML 配置文件
使用 XML 配置文件轻易地配置 PHP 应用程序和对象
级别: 中级
Vikram Vaswani, 创始人, Melonfire
2007 年 11 月 29 日
XML 为应用程序配置文件提供了一种便捷、易用的表达语言。但有时候将这些信息提取到 PHP 脚本中将会面对一个不小的挑战。这正是 XJConf for PHP 包出现的原因:它提 ......

C#中对XML节点进行增删改查

号称xmlhelper的一个类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
namespace WebApplication2
{
/// <summary>
/// XMLHelper XML文档操作管理器
/// </summary>
public class XMLHelper
{
public X ......

更新 xml步骤

在service(spring)中完成
step 1:
打开一个session
写 sql 语句,
注意点:写sql语句时,所查询的试图为:kangaroo_VW_UnitView,此试图的生成
有 kangaroo_unit表左连接到kangaroo_img表而生成。
step 2:
把所查询的符合条件的集合放入临时的ArrayList中,并对临时的ArrayList进行
迭代。
step 3:
把迭代出来的集 ......

VC对于XML的解析以及操作

XML的查找
#include <stdio.h>
#include <iostream>
#import <msxml4.dll>
#include <string>
using namespace std;
void Travel(MSXML2::IXMLDOMNodePtr pDOMNode)
{
 if (pDOMNode->GetnodeTypeString()==(_bstr_t)"element") // 获取节点类型
 {
  printf("%s ......

Asp.Net XML操作基类(修改,删除,新增,创建)

/############################################
版权声明:
文章内容为本站编辑,创作.你可以任意转载、发布、使用但请务必以明文标注文章原始出处及本声明
作者:浪淘沙
############################################/
/****************************************************************
* 更新内容: 1,根据父节点 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号