利用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
相关文档:
public class Fibonacci {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
NumOfFibonacci(9);
}
public static int MyFibonacci(int i){
if(i>0) {
if(i == 1)return 1;
if(i == 2)return 1;
else return MyFibonacc ......
/**
* 找出四位数所有的吸血鬼数字
* 吸血鬼数字:位数为偶数的数字可以由一对数字相乘而得,这对数字包含乘积一半的位数
* 如:1260 = 21*60
*/
public class Vampire {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String s= ......
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 ......
1.了解Java的原理:
首先要了解整个Java的大致结构、工作环境、历史。在这个过程中要搞明白Java从源代码到最后虚拟机里面执行的一个过程是怎样的。
2.学习Java语法:
Java里面只有50多个关键字和一些运算符。语法结构就只有顺序、条件、循环 ......