Absent Member.. DBR Absent Member..
Absent Member..
561 views

xPath/xPathQuery question

Jump to solution

I am making a call to a Service Manager WSDL.  I have attached what I am sending and what I am getting back.  The xPathQuery I am doing in OO is below.  I don't know where the attachments went.

In the request there are 10 fields being requested but only two are being returned in the xml since they are empty fields.

 

//SizeMB/text() | //DiskType/text() | //Volume/text() | //Group/text() | //Owner/text() | //PartitionDirectoryMountPoint/text() | //Permissions/text() | //SharedHost/text() | //SharedHostName/text() | //Notes/text()

 

The about works great IF the SM WSDL returns all of the fields.  If it doesn't it puts the first value in SizeMB even though that is not what it is.

 

Is there anyway around this?

 

Thanks,

Don

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: xPath/xPathQuery question

Jump to solution


Actually your problem is not related with OO but XML. Without the attachments it is a little hard to help you. What are you trying to do with your XPath query? I think sample below will be helping you about getting the output values:

 

try to get value with concat function: concat( //SizeMB[node()] ,'${yourDelimiter}', //DiskType[node()] , '${yourDelimiter}' , //Volume[node()] )

 

sample returnXML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:smpl="http://sampleLink">
<soapenv:Header />
<soapenv:Body>
<smpl:ResultList>
<!--SizeMB>sizeMB val</SizeMB-->
<DiskType>DiskType val</DiskType>
<Volume>volume val</Volume>
</smpl:ResultList>
</soapenv:Body>
</soapenv:Envelope>


*sample XPath queries to get the values:

for SizeMB:
//SizeMB/text()
or
//SizeMB[node()]
or
/*[local-name()='Envelope' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='Body' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='ResultList' and namespace-uri()='http://sampleLink']/SizeMB/text()

 

for DiskType:
//DiskType/text()
or
//DiskType[node()]
or
/*[local-name()='Envelope' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='Body' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='ResultList' and namespace-uri()='http://sampleLink']/DiskType/text()

 

Maybe this link will help you: http://stackoverflow.com/questions/4489976/xpath-to-return-default-value-if-node-not-present

 

Best Regards.

0 Likes
2 Replies
Highlighted
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: xPath/xPathQuery question

Jump to solution


Actually your problem is not related with OO but XML. Without the attachments it is a little hard to help you. What are you trying to do with your XPath query? I think sample below will be helping you about getting the output values:

 

try to get value with concat function: concat( //SizeMB[node()] ,'${yourDelimiter}', //DiskType[node()] , '${yourDelimiter}' , //Volume[node()] )

 

sample returnXML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:smpl="http://sampleLink">
<soapenv:Header />
<soapenv:Body>
<smpl:ResultList>
<!--SizeMB>sizeMB val</SizeMB-->
<DiskType>DiskType val</DiskType>
<Volume>volume val</Volume>
</smpl:ResultList>
</soapenv:Body>
</soapenv:Envelope>


*sample XPath queries to get the values:

for SizeMB:
//SizeMB/text()
or
//SizeMB[node()]
or
/*[local-name()='Envelope' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='Body' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='ResultList' and namespace-uri()='http://sampleLink']/SizeMB/text()

 

for DiskType:
//DiskType/text()
or
//DiskType[node()]
or
/*[local-name()='Envelope' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='Body' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']/*[local-name()='ResultList' and namespace-uri()='http://sampleLink']/DiskType/text()

 

Maybe this link will help you: http://stackoverflow.com/questions/4489976/xpath-to-return-default-value-if-node-not-present

 

Best Regards.

0 Likes
Absent Member.. DBR Absent Member..
Absent Member..

Re: xPath/xPathQuery question

Jump to solution
This works. Thank you very much!

Don
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.