title: How to get substrings from an Xpath using C#?
body: <p>I have an <code>Xpath</code> property inside of a JSON file and I'd like to get two substrings from this Xpath to assisting these substrings into two variables.</p>
  
  <p>The JSON object is as follows;</p>
  
  <pre class="lang-js prettyprint-override"><code>    {
          'selectGateway':'0',
          'waitingTime':'20000',
          'status':'200',
          'correlationID':'1',
          'matchString':[{'xpath':'/whitelist/locations/location/var-fields/var-field[@key="whitelist-entry" and @value="8.0440147AA44A80"]','value':''}],
          'matchInteger':[],
          'matchSortedList':[]
  
      }
  </code></pre>
  
  <p>This is my attempt so far it's working properly, I'm just looking for a way to do this more dynamically and in a better way if it's possible.</p>
  
  <pre><code>int firstStringPositionForKey = matchString[index].xpath.IndexOf("@key=\"");
  int secondStringPositionForKey = matchString[index].xpath.IndexOf("\" and");
  string betweenStringForKey = matchString[index].xpath.Substring(firstStringPositionForKey+6, secondStringPositionForKey-firstStringPositionForKey-6);
  
  int firstStringPositionForValue = matchString[index].xpath.IndexOf("@value=\"");
  int secondStringPositionForValue = matchString[index].xpath.IndexOf("\"]");
  string betweenStringForValue = matchString[index].xpath.Substring(firstStringPositionForValue+8, secondStringPositionForValue-firstStringPositionForValue-8);
  </code></pre>
  
  <p>I expect the output to be like: </p>
  
  <pre><code>key is : whitelist-entry
  value is : 8.0440147AA44A80
  </code></pre>