title: Pull value of a particular node using XPath
body: <p>I am facing an issue to pull value from a particular node in XML using XPath. What I'm trying to do is to get a value from a node based on a value in other node. So the value in the other node is a condition when I'm querying an XML.</p>
  
  <p>Here's my XPath code in C#:</p>
  
  <p>I can pull the value using the position of the node. </p>
  
  <pre><code>String webURL3;
              WebRequest YRCRateQuote;
              WebResponse resp3;
              Stream respStream3;
              XmlDocument rateQuote3 = new XmlDocument();
              XmlNode freightChargeSP1;
              XmlNode freightChargeSP2;
              XmlNode freightChargeSP3;
              XmlNode freightChargeSP4;
              XmlNode freightChargeSP5;
              XmlNode freightChargeSP6;
              XmlNode freightChargeSP7;
              XmlNode serviceDaysSP;
  
  
              //build web request
              webURL3 = String.Format(web service string);
  
              //create web request
              YRCRateQuote = WebRequest.Create(webURL3);
  
              //make web service call
              resp3 = YRCRateQuote.GetResponse();
  
              //read response 
              respStream3 = resp3.GetResponseStream();
              rateQuote3.Load(respStream3);
  
              //Use Name Space
              XmlNamespaceManager nsmgr = new XmlNamespaceManager(rateQuote3.NameTable);
              nsmgr.AddNamespace("rq", "http://ratequote.usfnet.usfc.com/v2/x1");
  
  //This works get the value of the first TOTAL_COST node
  freightChargeSP2 = rateQuote3.SelectSingleNode("//rq:SERVICEUPGRADES[1]//rq:TOTAL_COST", nsmgr);
  
  //But this one gives me null if I want to pull the value depending upon value in the other node
  freightChargeSP1 = rateQuote3.SelectSingleNode("//rq:SERVICEUPGRADES[SERVICE_TYPE='regional delivery']//rq:TOTAL_COST", nsmgr);
  
  //I also tried doing this
  freightChargeSP1 = rateQuote3.SelectSingleNode("//rq:SERVICEUPGRADES//rq:TOTAL_COST[SERVICE_TYPE='regional delivery']", nsmgr);
  </code></pre>
  
  <p>Changing // to / didn't help it either.</p>
  
  <p>Here's the XML:</p>
  
  <pre><code>    &lt;?xml version="1.0"?&gt;
  &lt;RateQuoteResponse xmlns="http://ratequote.usfnet.usfc.com/v2/x1"&gt;
    &lt;STATUS&gt;
      &lt;CODE&gt;0&lt;/CODE&gt;
      &lt;VIEW&gt;SECURED&lt;/VIEW&gt;
      &lt;VERSION&gt;
        &lt;CURRENT&gt;V2X1&lt;/CURRENT&gt;
        &lt;CURRENT_RELEASE_DATE&gt;02/06/2010&lt;/CURRENT_RELEASE_DATE&gt;
        &lt;LATEST&gt;V2X1&lt;/LATEST&gt;&lt;LATEST_RELEASE_DATE&gt;02/06/2010&lt;/LATEST_RELEASE_DATE&gt;
      &lt;/VERSION&gt;&lt;/STATUS&gt;
    &lt;RateQuote&gt;
      &lt;ORIGIN&gt;
        &lt;NAME&gt;INDIANAPOLIS&lt;/NAME&gt;
        &lt;CARRIER&gt;USF Holland, Inc&lt;/CARRIER&gt;
        &lt;ADDRESS&gt;2530 S TIBBS AVE&lt;/ADDRESS&gt;
        &lt;CITY&gt;INDIANAPOLIS&lt;/CITY&gt;
        &lt;STATE&gt;IN&lt;/STATE&gt;
        &lt;ZIP&gt;46241&lt;/ZIP&gt;
        &lt;PHONE&gt;3172277627&lt;/PHONE&gt;
        &lt;PHONE_TOLLFREE&gt;8006274831&lt;/PHONE_TOLLFREE&gt;
        &lt;FAX&gt;3172277629&lt;/FAX&gt;
      &lt;/ORIGIN&gt;
      &lt;DESTINATION&gt;
        &lt;NAME&gt;INDIANAPOLIS&lt;/NAME&gt;
        &lt;CARRIER&gt;USF Holland, Inc&lt;/CARRIER&gt;
        &lt;ADDRESS&gt;2530 S TIBBS AVE&lt;/ADDRESS&gt;
        &lt;CITY&gt;INDIANAPOLIS&lt;/CITY&gt;
        &lt;STATE&gt;IN&lt;/STATE&gt;
        &lt;ZIP&gt;46241&lt;/ZIP&gt;
        &lt;PHONE&gt;3172277627&lt;/PHONE&gt;
        &lt;PHONE_TOLLFREE&gt;8006274831&lt;/PHONE_TOLLFREE&gt;
        &lt;FAX&gt;3172277629&lt;/FAX&gt;
      &lt;/DESTINATION&gt;
      &lt;ORIGIN_ZIP&gt;46202&lt;/ORIGIN_ZIP&gt;
      &lt;DESTINATION_ZIP&gt;46204&lt;/DESTINATION_ZIP&gt;
      &lt;TOTAL_COST&gt;117.02&lt;/TOTAL_COST&gt;
      &lt;DISCOUNTPERCENTAGE&gt;85.0&lt;/DISCOUNTPERCENTAGE&gt;
      &lt;DISCOUNTAMOUNT&gt;512.04&lt;/DISCOUNTAMOUNT&gt;
      &lt;SERVICEDAYS&gt;1&lt;/SERVICEDAYS&gt;
      &lt;INDUSTRYDAYS&gt;1.5&lt;/INDUSTRYDAYS&gt;
      &lt;CLASSWEIGHT&gt;
        &lt;CLASS&gt;60&lt;/CLASS&gt;
        &lt;ASCLASS&gt;60&lt;/ASCLASS&gt;
        &lt;WEIGHT&gt;1500&lt;/WEIGHT&gt;
        &lt;CHARGES&gt;602.4&lt;/CHARGES&gt;
      &lt;/CLASSWEIGHT&gt;
      &lt;ADDIONALCHARGES&gt;
        &lt;RATE&gt;Fuel Surcharge&lt;/RATE&gt;
        &lt;CHARGES&gt;26.66&lt;/CHARGES&gt;
        &lt;DESCRIPTION&gt;FSC29.50% ON DIESEL OF 386.7&lt;/DESCRIPTION&gt;
      &lt;/ADDIONALCHARGES&gt;
      &lt;SERVICEUPGRADES&gt;
        &lt;DELIVERYDAYS&gt;Please Call Customer Service for Available Days and Times&lt;/DELIVERYDAYS&gt;
        &lt;DELIVERYTIME&gt;Single-hour Window&lt;/DELIVERYTIME&gt;
        &lt;SERVICE_TYPE&gt;guaranteed window&lt;/SERVICE_TYPE&gt;
        &lt;TOTAL_COST&gt;267.02&lt;/TOTAL_COST&gt;
      &lt;/SERVICEUPGRADES&gt;
      &lt;SERVICEUPGRADES&gt;
        &lt;DELIVERYDAYS&gt;Please Call Customer Service for Available Days and Times&lt;/DELIVERYDAYS&gt;
        &lt;DELIVERYTIME&gt;Multi-hour Window&lt;/DELIVERYTIME&gt;
        &lt;SERVICE_TYPE&gt;guaranteed window&lt;/SERVICE_TYPE&gt;
        &lt;TOTAL_COST&gt;267.02&lt;/TOTAL_COST&gt;
      &lt;/SERVICEUPGRADES&gt;
      &lt;SERVICEUPGRADES&gt;
        &lt;DELIVERYDAYS&gt;Please Call Customer Service for Available Days and Times&lt;/DELIVERYDAYS&gt;
        &lt;DELIVERYTIME&gt;Single or Multi Day Window&lt;/DELIVERYTIME&gt;
        &lt;SERVICE_TYPE&gt;guaranteed window&lt;/SERVICE_TYPE&gt;
        &lt;TOTAL_COST&gt;152.02&lt;/TOTAL_COST&gt;
      &lt;/SERVICEUPGRADES&gt;
      &lt;SERVICEUPGRADES&gt;
        &lt;DELIVERYDATE&gt;07/17/2013&lt;/DELIVERYDATE&gt;
        &lt;DELIVERYDAYS&gt;1&lt;/DELIVERYDAYS&gt;
        &lt;DELIVERYTIME&gt;before 9:00 AM&lt;/DELIVERYTIME&gt;
        &lt;SERVICE_TYPE&gt;guaranteed delivery&lt;/SERVICE_TYPE&gt;
        &lt;TOTAL_COST&gt;217.02&lt;/TOTAL_COST&gt;
      &lt;/SERVICEUPGRADES&gt;
      &lt;SERVICEUPGRADES&gt;
        &lt;DELIVERYDATE&gt;07/17/2013&lt;/DELIVERYDATE&gt;
        &lt;DELIVERYDAYS&gt;1&lt;/DELIVERYDAYS&gt;
        &lt;DELIVERYTIME&gt;before 12:00 PM (noon)&lt;/DELIVERYTIME&gt;
        &lt;SERVICE_TYPE&gt;guaranteed delivery&lt;/SERVICE_TYPE&gt;
        &lt;TOTAL_COST&gt;182.02&lt;/TOTAL_COST&gt;
      &lt;/SERVICEUPGRADES&gt;
      &lt;SERVICEUPGRADES&gt;
        &lt;DELIVERYDATE&gt;07/17/2013&lt;/DELIVERYDATE&gt;
        &lt;DELIVERYDAYS&gt;1&lt;/DELIVERYDAYS&gt;
        &lt;DELIVERYTIME&gt;before 3:30 PM&lt;/DELIVERYTIME&gt;
        &lt;SERVICE_TYPE&gt;guaranteed delivery&lt;/SERVICE_TYPE&gt;
        &lt;TOTAL_COST&gt;152.02&lt;/TOTAL_COST&gt;
      &lt;/SERVICEUPGRADES&gt;
      &lt;SERVICEUPGRADES&gt;
        &lt;DELIVERYDATE&gt;07/17/2013&lt;/DELIVERYDATE&gt;
        &lt;DELIVERYDAYS&gt;1&lt;/DELIVERYDAYS&gt;
        &lt;SERVICE_TYPE&gt;regional delivery&lt;/SERVICE_TYPE&gt;
        &lt;TOTAL_COST&gt;117.02&lt;/TOTAL_COST&gt;
      &lt;/SERVICEUPGRADES&gt;
    &lt;/RateQuote&gt;
  &lt;/RateQuoteResponse&gt;
  </code></pre>