Ashok.N
Ashok.N

Reputation: 1391

Unable to get the node value using XPATH

I have the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP:Body>
      <performJob loadfromcache="yes">
         <jobName>PQIssueDetails</jobName>
         <whiteboard>
            <PQ>
               <hostAddress>21212</hostAddress>
               <hostPort>12955</hostPort>
               <timeout>120000</timeout>
               <trace>0</trace>
               <readable>N</readable>
               <userID>2121</userID>
               <password>XXX@1</password>
               <currentDate>8/28/2015 10:31 AM</currentDate>
               <AWD10SP7_1orhigher>Y</AWD10SP7_1orhigher> 
               <METHOD>GET</METHOD>
               <eao>08272015</eao>
               <storedProcedure id="PQISSUEDETAIL">
                  <parameter id="P_CRDATTIM">
                     <value>2015-08-25-01.40.19.219580</value>
                     <dataType>string</dataType>
                  </parameter>
                  <parameter id="P_RECORDCD">
                     <value>T</value>
                     <dataType>string</dataType>
                  </parameter>
                  <parameter id="P_CRNODE">
                     <value>01</value>
                     <dataType>string</dataType>
                  </parameter>
               </storedProcedure>
            </PQ>
         </whiteboard>
         <requestNodeName>.</requestNodeName>
         <responseNodeName>//PQ</responseNodeName>
         <jobDB>
            <name>PQCustomerService</name>
            <userID>sa</userID>
            <password>password</password>
         </jobDB>
      </performJob>
   </SOAP:Body>
</SOAP:Envelope>

I want to get only the value of <value> of the first parameter under <storedProcedure> tag.

I am trying with the following XPATH, but it's not working

//PQ/storedProcedure/parameter[1]/@value

I think I am doing something wronghere while using XPATH Could you please help me on this?

Upvotes: 0

Views: 67

Answers (1)

splash58
splash58

Reputation: 26153

Value is not attribute but tag, so use xpath

//PQ/storedProcedure/parameter[1]/value

Upvotes: 2

Related Questions