VMware Cloud Community
Sirry
Enthusiast
Enthusiast
Jump to solution

(general) Task XML Help?

I am having trouble accessing items that are empty in XML (no children). Whenever I emulate the examples in the notifications package, the variables I use return null/nothing. Can someone point me in the right direction? I'm sure I'm doing something wrong, I just don't know what. I have highlighted an example item in the following example task where I am having issues extracting data (the name field in particular).

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<ns6:Task xmlns="http://www.vmware.com/vcloud/versions" xmlns:ns2="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ns3="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ns4="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ns5="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:ns6="http://www.vmware.com/vcloud/v1.5" xmlns:ns7="http://www.vmware.com/schema/ovf" xmlns:ns8="http://schemas.dmtf.org/ovf/environment/1" xmlns:ns9="http://www.vmware.com/vcloud/extension/v1.5" status="preRunning" startTime="2013-06-13T19:00:21.698-07:00" serviceNamespace="com.vmware.vcloud" operationName="vdcRecomposeVapp" operation="Recomposing Virtual Application jjhllllllllgvvu(357e4030-0b68-4fdf-bbce-b4ef8995f173)" expiryTime="2013-09-11T19:00:21.698-07:00" cancelRequested="false" name="task" id="urn:vcloud:task:77be7776-df5e-4bc0-9314-dc3810573f9e" type="application/vnd.vmware.vcloud.task+xml" href="https://usyp-vcd.kingstonlab.corp/api/task/77be7776-df5e-4bc0-9314-dc3810573f9e">

    <ns6:Link rel="down" type="application/vnd.vmware.admin.blockingTask+xml" href="https://usyp-vcd.kingstonlab.corp/api/admin/extension/blockingTask/847bb7ba-3a8a-4ce0-baf0-4b039cc89..."/>

    <ns6:Owner type="application/vnd.vmware.vcloud.vApp+xml" name="jjhllllllllgvvu" href="https://usyp-vcd.kingstonlab.corp/api/vApp/vapp-357e4030-0b68-4fdf-bbce-b4ef8995f173"/>

    <ns6:User type="application/vnd.vmware.admin.user+xml" name="eshen_auth" href="https://usyp-vcd.kingstonlab.corp/api/admin/user/538b77ae-0c6c-4ea1-bd95-15e1dcc71814"/>

    <ns6:Organization type="application/vnd.vmware.vcloud.org+xml" name="lab-AdminOrg" href="https://usyp-vcd.kingstonlab.corp/api/org/809f461e-f36b-4b00-b5ab-56e3a8b44fe7"/>

    <ns6:Progress>1</ns6:Progress>

    <ns6:Params xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns6:RecomposeVAppParamsType">

        <ns6:DeleteItem type="application/vnd.vmware.vcloud.vm+xml" name="centos6.2-1" href="https://usyp-vcd.kingstonlab.corp/api/vApp/vm-82875434-0de1-422c-b57e-f19aac31ea77"/>

    </ns6:Params>

    <ns6:Details>blockingTask.pendingStatus</ns6:Details>

</ns6:Task>

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Sirry
Enthusiast
Enthusiast
Jump to solution

Thanks Dirty,

I have not tested your method, but I was able to solve this using another method.

I did so by using the following variable assignment:

(taskDoc is the XML for the task)

var items = taskDoc.Params;

var del = items.*::DeleteItem.@*::name.toString();

As a side note - this was indeed shown in the notifications package, contrary to what I stated in my question - I just wasn't looking in the right location.

View solution in original post

0 Kudos
2 Replies
Dirty_Hipster
Enthusiast
Enthusiast
Jump to solution

I used to read XML file from resource element. The following codes work fine with me:

var xmlString = XMLFile.getContentAsMimeAttachment().content;

xmlString = xmlString.substring(1,xmlString.length); // Sometimes, the xml file starts with a white space, and you want to eliminate that!

var text = XMLManager.newDocument();

text = XMLManager.fromString(xmlString); // convert string back to XML type

var nodeList = text.getElementsByTagName("ServerName");

Now, you can play with the nodeList to extract all the info you need.

Sirry
Enthusiast
Enthusiast
Jump to solution

Thanks Dirty,

I have not tested your method, but I was able to solve this using another method.

I did so by using the following variable assignment:

(taskDoc is the XML for the task)

var items = taskDoc.Params;

var del = items.*::DeleteItem.@*::name.toString();

As a side note - this was indeed shown in the notifications package, contrary to what I stated in my question - I just wasn't looking in the right location.

0 Kudos