fix NPE on centos when dumpxml

This commit is contained in:
Edison Su 2011-03-24 11:33:30 -04:00
parent c93abe014c
commit 954dacdbda
1 changed files with 20 additions and 14 deletions

View File

@ -137,21 +137,27 @@ public class LibvirtDomainXMLParser {
return false;
}
private static String getTagValue(String tag, Element eElement){
NodeList nlList= eElement.getElementsByTagName(tag).item(0).getChildNodes();
Node nValue = (Node) nlList.item(0);
return nValue.getNodeValue();
}
private static String getTagValue(String tag, Element eElement){
NodeList tagNodeList = eElement.getElementsByTagName(tag);
if (tagNodeList == null || tagNodeList.getLength() == 0) {
return null;
}
private static String getAttrValue(String tag, String attr, Element eElement){
NodeList tagNode = eElement.getElementsByTagName(tag);
if (tagNode.getLength() == 0) {
return null;
}
Element node = (Element)tagNode.item(0);
return node.getAttribute(attr);
}
NodeList nlList= tagNodeList.item(0).getChildNodes();
Node nValue = (Node) nlList.item(0);
return nValue.getNodeValue();
}
private static String getAttrValue(String tag, String attr, Element eElement){
NodeList tagNode = eElement.getElementsByTagName(tag);
if (tagNode.getLength() == 0) {
return null;
}
Element node = (Element)tagNode.item(0);
return node.getAttribute(attr);
}
public Integer getVncPort() {
return vncPort;