package w3c;
import java.io.File;
import java.io.IOException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
public class ParseXmlWithW3c {
/**
* @param args
*/
public static void main(String[] args)
{
File file = new File("E:\\projectdevelop\\example\\example\\src\\w3c\\actionOperation.xml");
DOMParser parser = new DOMParser();
try {
parser.parse("E:\\projectdevelop\\example\\example\\src\\w3c\\actionOperation.xml");
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Document doc = parser.getDocument();
Element rootEle = doc.getDocumentElement();
NodeList nodeList = rootEle.getElementsByTagName("operation");
for (int i = 0; i<nodeList.getLength();i++)
{
Element operationEle = (Element)nodeList.item(i);
NodeList actionChileEle = operationEle.getElementsByTagName("action_type");
String actionType = (null == actionChileEle.item(0).getFirstChild()) ? "" : actionChileEle.item(0).getFirstChild().getNodeValue().trim();
System.out.println("action_type" + i + " = " + actionType);
NodeList operChileEle = operationEle.getElementsByTagName("operation_type");
String operationType = (null == operChileEle.item(0).getFirstChild()) ? "" : operChileEle.item(0).getFirstChild().getNodeValue().trim();
System.out.println("operation_type" + i + " = " + operationType);
NodeList isCopyChileEle = operationEle.getElementsByTagName("is_copy");
String coypType = (null == isCopyChileEle.item(0).getFirstChild()) ? "" : isCopyChileEle.item(0).getFirstChild().getNodeValue().trim();
System.out.println("coypType" + i + " = " + coypType);
}
}
}
分享到:
相关推荐
w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码w3c源码
w3school c语言教程 20141228
w3school c语言教程 飞龙整理 20141103
W3C整站下载后保存为chm格式电子文档
W3C 词汇与字典 - "W3C Glossary and Dictionary" 的中文译文。 原始版本:http://www.w3.org/2003/glossary/ 翻译:W3School 项目组 尊敬的读者朋友们请注意,这是关于 W3C 文章的网页翻译。 原文版权受法律...
w3c-dom.jar 包 dom解析xml使用 包 免积分下载
w3c文档中文版
介绍了W3C标准的目的、目标、受众、标准内容
W3C中文文档
w3c 手册 w3c 手册 w3c 手册 w3c 手册
W3C全套开发文档包含 html,xhtml,html5,css,tcp/ip,xml,javascript,Ajax,Jquery,E4X,XMLscript,SQL,ASP,php,ado,.net等等
w3c 生成xml 文件w3c 生成xml 文件w3c 生成xml 文件
W3C School是一家专门提供Web技术在线教程的网站。网站中提供了大量全面的Web开发相关手册、实例。这里要提供给大家的就是由该网站内容整理的CHM手册——离线版的W3C School网站,方便大家在Web开发时使用。 该手册...
w3c标准体验文档。展示w3c的标准内容,方便广大用户使用。为您带来全方位的w3c标准。容你更加了解,清楚知道w3c标准是什么。
W3C JavaScript 高级教程 W3C JavaScript 高级教程
DOM W3C标准操作XML读取,添加,删除,修改的一些简单代码,希望在关键的时候能帮上大家解决一些问题,能帮上的话,请大家多多捧场,没帮上的话,还请大家多多指教,谢谢
W3C标准代码简介
CSS 手册 Javascript手册 jQuery手册 xHTML手册 XMLHttp手册 W3CSchool手册 w3c标准html5手册
w3c html css js xml
W3C代码标准规范,及一些例子,检测自己的网站是否符号W3C标准的地址为http://validator.w3.org/