Re: Trying to do a query inside my XML but not sure what to do. (143 Views)
Reply
Trusted Contributor
DBR
Posts: 211
Registered: ‎07-29-2010
Message 1 of 3 (171 Views)

Trying to do a query inside my XML but not sure what to do.

Trying to do a query inside my XML but not sure what to do.

 

This is the XML.  I need to get the relationship.name where it is LIKE "-PROD".  Does anybody know how to do this?

 

Thanks,

Don

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://schemas.hp.com/SM/7" xmlns:com="http://schemas.hp.com/SM/7/Common" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:RetrieveooCIRelationshipKeysListRequest attachmentInfo="" attachmentData="" ignoreEmptyElements="true" updatecounter="" handle="" count="" start="">
         <ns:model query="">
            <ns:keys query="" updatecounter="">
               <!--Optional:-->
               <ns:relationship.name type="String" mandatory="" readonly="">?</ns:relationship.name>
               <!--Optional:-->
               <ns:logical.name type="String" mandatory="" readonly="">?</ns:logical.name>
            </ns:keys>
            <ns:instance query="" uniquequery="" recordid="" updatecounter="">
               <!--Optional:-->
               <ns:logical.name type="String" mandatory="" readonly="">?</ns:logical.name>
               <!--Optional:-->
               <ns:relationship.name type="String" mandatory="" readonly="">?</ns:relationship.name>
               <!--Optional:-->
               <ns:relationship.type type="String" mandatory="" readonly="">?</ns:relationship.type>
               <!--Optional:-->
               <ns:relationship.subtype type="String" mandatory="" readonly="">?</ns:relationship.subtype>
               <!--Optional:-->
               <ns:attachments>
                  <!--Zero or more repetitions:-->
                  <com:attachment xm:contentType="application/?" href="" contentId="" action="" name="" type="" len="" charset="" attachmentType="">cid:393818817546</com:attachment>
               </ns:attachments>
            </ns:instance>
            <!--Optional:-->
            <ns:messages>
               <!--Zero or more repetitions:-->
               <com:message severity="" module="">?</com:message>
            </ns:messages>
         </ns:model>
      </ns:RetrieveooCIRelationshipKeysListRequest>
   </soapenv:Body>
</soapenv:Envelope>

Trusted Contributor
Steve_Drummond
Posts: 89
Registered: ‎10-01-2012
Message 2 of 3 (146 Views)

Re: Trying to do a query inside my XML but not sure what to do.

[ Edited ]

Hi Don,

 

If you are using HPOO 9.x you can use the XPath filter in the results tab to perform an XPath query against the XML; if you are using 7.51 or as an alternative to a filter there is an XPath operation under /lib/util/xml processing.

 

There are two instances of relationship.name in the XML you provided so not sure which one you want (or both?); also not sure if you just want the value or the entire XML tag.

 

This XPath will get you the values for n number of tags

ns:relationship.name[contains(.,'-PROD')]/text()

 

If you want the entire tag returned simply remove the /text() component.

 

If you only want one of them returned you need to specify the parent tag of either ns:keys or ns:instance like below

//ns:instance/ns:relationship.name[contains(.,'-PROD')]/text()

 

Please note that XPath is case sensitive so it will not find -prod or -Production etc. XPath 2.0 allows for some case insensitivity but HPOO only uses XPath 1.0. There is a workaround for XPath 1.0 using the translate() function but it's very messy.

 

If you want to return n number of values (instead of just one) you won't be able to use the XPath filters as they only return the first result unfortunately.

 

Hope this helps.

 

-steve

Trusted Contributor
DBR
Posts: 211
Registered: ‎07-29-2010
Message 3 of 3 (143 Views)

Re: Trying to do a query inside my XML but not sure what to do.

Steve,

 

I don't want to do it in the result.  There are over 20k records that would be returned from HPSM.  I want to do it when I am doing the call to HPSM.

 

Thanks,

Don

 

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.