Question: I am trying to get the value for applicationId from the following request through xpath :-

```
<ApplicationStatusNotificationRequestMessage xmlns="http://schemas.co.za/application">
    <b>http://localhost/test/sonoras</b>
    <c>POST</c>
    <Data><![CDATA[{"applicationId":"12345678","status":"ACTIVATED"}]]></Data>
</ApplicationStatusNotificationRequestMessage>

```

The xpath expression I am using:

```
//app:ApplicationStatusNotificationRequestMessage/app:Data[@applicationId]/text()

```

Unfortunately, the XPath is not returning any value.

Answer: 
The JSON content inside your `<d>` element is just a `text()` node. The "applicationId" in your JSON string will not be evaluated as an attribute. The fact that CDATA was used is irrelevant. 

Your predicate is attempting to select the `text()` from `app:Data` elements that have an `@applicationId`, and there are none.

Use the [`contains()`](http://www.w3.org/TR/xpath/#function-contains) function to restrict to elements that have that JSON property in the `text()`

```
//app:ApplicationStatusNotificationRequestMessage/
  app:Data[contains(., 'applicationId')]/text()

```

If you want to obtain the applicationId value, you will need to parse the JSON string. There are a number of ways to do that. Depending upon which version of XPath you are using, you will have more/less options. A few examples of how you might obtain the value:

**XPath 3.0** - using [json-to-xml()](https://www.w3.org/2005/xpath-functions/#json-to-xml):

```
json-to-xml(//app:ApplicationStatusNotificationRequestMessage/
        app:Data[contains(., 'applicationId')]/text())/*/*[@key='applicationId']/text()

```

**XPath 2.0** - using [replace()](https://www.w3.org/2005/xpath-functions/#replace):

```
replace(//app:ApplicationStatusNotificationRequestMessage/
        app:Data[contains(., 'applicationId')]/text(), '.*applicationId.*?:.(\d+).,.*', '$1')

```

**XPath 1.0** - using [substring-before()](https://www.w3.org/2005/xpath-functions/#substring-before) and [substring-after()](https://www.w3.org/2005/xpath-functions/#substring-after):

```
substring-before(
  substring-after(//app:ApplicationStatusNotificationRequestMessage/
                    app:Data[contains(., 'applicationId')]/text(), 
         'applicationId&quot;:&quot;'), 
  '&quot;,')

```
If you can't register a namespace you can go with this:

```
"/*[name()='ApplicationStatusNotificationRequestMessage']/*[name()='Data']"

```