利用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
相关文档:
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
在tomcat中发布web项目,可能是因为spring中配置了jndi(只配置了jndi,其他的有工具包封装了)。
启动的时候报错(在项目目录下,在tomcat中配置context指向项目目录就没问题,打包发布到
tomcat就报错了),抛的异常是:
jav ......
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事件基类,即java.util.EventObject;EventObject(Object source)是EventObject唯一的构造方法,这意味着所有事件必须在实例化时就指定事件源 ......
java中的事件机制的参与者有3种角色:
1.event object:就是事件产生时具体的“事件”,用于listener的相应的方法之中,作为参数,一般存在与listerner的方法之中
2.event source:具体的接受事件的实体,比如说,你点击一个button,那么button就是event source,这样你必须使button对某些事件进行相应,你就需 ......
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");
}
......