On Tuesday, 20 October 2015 at 13:23:47 UTC, opticron wrote:
I think part of the issue here is that holo isn't quite sure of what information [s]he needs out of the XML reply and how to do that with XPath. The first post mentioned getting instanceId and launchTime, so I'll start there using the AWS example XML found here: https://github.com/polopoly/cloud-ui/blob/master/aws/examples/DescribeInstances.xml

You can find all parent nodes that provide this set of information with XPath query "//instancesSet/item". From there, you can iterate over the list and pull out the information you need:

auto parents = root.parseXPath("//instancesSet/item");
foreach(parent; parents) {
string instanceId = parent.parseXPath("instanceId")[0].getCData(); string launchTime = parent.parseXPath("launchTime")[0].getCData();
}

In the process of checking this out, I discovered that subnode predicates are broken (attribute predicates work just fine, I need to write more unittests). I guess I have some things to work on tonight.

Sorry i augment you work ;) . I was continuing with my project i came across next problem.

When im checking instance name with such code:

auto test = list.parseXPath(`//tagSet/item[key="Name"]/value`)[0].goCData;

it is compiling properly but it is breaking program when is no name set.

I make quick workaround:

    auto tmp = list.parseXPath(`//tagSet/item[key="Name"]/value`);
            if(tmp == null)
            {
                instances[tmpinst].instanceName = "";
            }
            else
            {
auto instances[tmpinst].instanceName = tmp[0].getCData;
            }


but is there any reason why it is not taken into consideration in "getCData" method?


Reply via email to