Question: This is the HTML I want to extract from.

```
<input type="hidden" id="continueTo" name="continueTo" value="/oauth2/authz/?response_type=code&client_id=localoauth20&redirect_uri=http%3A%2F%2Fbg-sip-activemq%3A8080%2Fjbpm-console%2Foauth20Callback&state=72a37ba7-2033-47f4-8e7e-69a207406dfb" />

```

I need a Xpath to extract only state value i.e `72a37ba7-2033-47f4-8e7e-69a207406dfb`

Answer: 
Hi you can only get value of a attribute using xpath not its sub-string but if you want to get sub-string then please do it like below 

```
String AttributeValue = driver.findElement(By.id("continueTo")).getAttribute("value");
System.out.println("Value of the attribute value is : " + AttributeValue);

    // now as you want 72a37ba7-2033-47f4-8e7e-69a207406dfb this substring of the vale attribute 
    // then plz apply java split as below 
    String value = "/oauth2/authz/?response_type=code&client_id=localoauth20&redirect_uri=http%3A%2F%2Fbg-sip-activemq%3A8080%2Fjbpm-console%2Foauth20Callback&state=72a37ba7-2033-47f4-8e7e-69a207406dfb";
    String [] myValue = value.split("=");
    System.out.println(myValue[0]); // will print /oauth2/authz/?response_type
    System.out.println(myValue[1]); // will print code&client_id
    System.out.println(myValue[2]); // will print localoauth20&redirect_uri
    System.out.println(myValue[3]); // will print http%3A%2F%2Fbg-sip-activemq%3A8080%2Fjbpm-console%2Foauth20Callback&state
    System.out.println(myValue[4]); // will print 72a37ba7-2033-47f4-8e7e-69a207406dfb

```

Hope this helps your query
Use below code:-

```
    String val = driver.findElement(By.xpath("//input[@id='continueTo']/@value")).getText();

    String [] myValue = val.split("&state=");

    System.out.println(myValue[1]);

```

Hope it will help you :)