public IList<SearchResult> Search(string xpath)
{
if(string.IsNullOrWhiteSpace(xpath))
{
return new SearchResult[0];
}
var rootElement = _repository.GetRootElement();
if(rootElement == null)
{
return new SearchResult[0];
}
try
{
var matches = rootElement.Document?.XPathEvaluate(xpath);
var searchResults = _searchResultFactory.Parse(matches);
return searchResults;
}
catch(Exception ex)
{
throw new InvalidOperationException(PackageResources.XPathEvaluationErrorText, ex);
}
}