diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java index 58264ed402..ef09d592a8 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java @@ -37,6 +37,7 @@ public class DescribeSnapshotsResponseHandler extends ParseSax.HandlerWithResult private Set snapshots = Sets.newLinkedHashSet(); private final SnapshotHandler snapshotHandler; + private int itemDepth = 0; @Inject public DescribeSnapshotsResponseHandler(SnapshotHandler snapshotHandler) { @@ -50,13 +51,16 @@ public class DescribeSnapshotsResponseHandler extends ParseSax.HandlerWithResult @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + itemDepth++; snapshotHandler.startElement(uri, localName, qName, attributes); } @Override public void endElement(String uri, String localName, String qName) throws SAXException { snapshotHandler.endElement(uri, localName, qName); - if (qName.equals("item")) { + itemDepth--; + + if (qName.equals("item") && itemDepth == 2) { this.snapshots.add(snapshotHandler.getResult()); } } diff --git a/apis/ec2/src/test/resources/describe_snapshots.xml b/apis/ec2/src/test/resources/describe_snapshots.xml index d0355e592f..44e2c36f13 100644 --- a/apis/ec2/src/test/resources/describe_snapshots.xml +++ b/apis/ec2/src/test/resources/describe_snapshots.xml @@ -9,6 +9,12 @@ 218213537122 10 Daily Backup + + + Name + example_name_tag + + \ No newline at end of file