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

利用java Api解析XML

import java.io.IOException;
import java.io.StringReader;
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.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
 * Usage: You can get a instance of Document from a string of xml.
 * This class supply some method to read a document.
 *
 */
public class XMLParser {
 /**
  * Get a instance of Document from a string of xml.
  *
  * @param xmlStr
  * @return Document
  */
 public static Document parse(String xmlStr) {
  if (xmlStr == null) {
   return null;
  }
  StringReader reader = new StringReader(xmlStr);
  InputSource source = new InputSource(reader);
  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  DocumentBuilder builder = null;
  try {
   builder = factory.newDocumentBuilder();
   
  } catch (ParserConfigurationException e) {
   e.printStackTrace();
  }
  if(builder == null){
   return null;
  }
  Document doc = null;
  try {
   doc = builder.parse(source);
  } catch (SAXException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  return doc;
 }
 
 /**
  * Get Item Value.
  * @param node
  * @return String
  */
 public static String getItemValue(Node node){
  String value = "";
  if(node == null){
   retur


相关文档:

Java学习笔记(2)体验云计算

  现在,谈云计算的可多了,不过,一般比较关注的是Google和Amazon的云服务。从大范围来看,也只有这两家获得了公众的更多关注。比如,我个人很感兴趣的,就是Google的App Engine使用户能够在Google基础设施上构建和托管 Web 应用程序。至于Amazon,它的AmazonWeb Services还包括Elastic Cloud Compute (EC2)计算Web服 ......

Java & .NET

 http://www.gotapi.com/
 语言:英语
 简介:HTML,CSS,XPATH,XSL,JAVASCRIPT等API的查询网站。
http://www.w3schools.com/
 语言:英语
 简介:W3C制定的标准诸如XML,HTML,XSL等等的在线学习教程。
http://www.xml.org.cn/
 语言:中文
 简介:可以说是XML的中国官方网吧。W3C ......

Java中static、this、super、final 的用法

 本篇旨在帮助准备学习Java以及刚接触Java的朋友认识、掌握和使用static、this、super、final这几个关键字的使用。Java博大精深,我也是一位正在学习和使用Java的爱好者,文中难免有不妥之处,欢迎指正。
一、static
 请先看下面这段程序:
public class Hello{
  public static void main(String[] args){ ......

java获取程序当前目录。

import java.net.URL;
import java.net.URLDecoder;
public class PathUtil
{
 /**
  * Get the env of windir, such as "C:\WINDOWS".
  * @return the env of windir value.
  */
 public static String getWindir(){
  return System.getenv("windir");
 }
 
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号