1. 程式人生 > >String 和 document 的相互轉換總結

String 和 document 的相互轉換總結

獲取xml中某一節點內容: 

public static String getValueByTagName(Document doc, String tagName){
		if(doc == null || StringUtil.isNull(tagName)){
			return "";
		}
		NodeList pl = doc.getElementsByTagName(tagName);
		if(pl != null && pl.getLength() > 0){
			return StringUtil.dealParam(StringUtil.convertNull( pl.item(0).getTextContent()));
		}
		return "";
	}