public static String extractXPathPropertyValue(Object property, String pathExpression) {
try {
String value = property instanceof TestProperty ? ((TestProperty) property).getValue() : property
.toString();
if (pathExpression.startsWith("$")) {
return new JsonPathFacade(value).readStringValue(pathExpression);
} else {
XmlObject xmlObject = XmlUtils.createXmlObject(value);
String ns = pathExpression.trim().startsWith("declare namespace") ? "" : XmlUtils.declareXPathNamespaces(xmlObject);
Node domNode = XmlUtils.selectFirstDomNode(xmlObject, ns + pathExpression);
return domNode == null ? null : XmlUtils.getValueForMatch(domNode, false);