public void getResult(String xmlString)
throws UspMonitorException
{
String temp = xmlString.replace("xmlns", "xmlnss");
StringReader stringReader = new StringReader(temp);
SAXReader saxReader = new SAXReader();
VolumeSnapshotResult volumeSnapshotResult = null;
try
{
Document document = saxReader.read(stringReader);
Element rootElement = document.getRootElement();
List<Node> nodes = rootElement.selectNodes("./*");
//List<Node> nodes = rootElement.selectNodes("Root/Item/*");
for (Node node : nodes)
{
volumeSnapshotResult = new VolumeSnapshotResult();
String tmpTxt = node.getText();
String tmpName = node.getName();
if ("snapshotId".equals(tmpName))
{
volumeSnapshotResult.setSnapshotID(tmpTxt);
}
else if ("volumeId".equals(tmpName))
{
volumeSnapshotResult.setVolumeID(tmpTxt);
}
}
}
catch (DocumentException e)
{
e.printStackTrace();
}
}
dom4j
最新推荐文章于 2022-03-11 10:48:24 发布