public static XElement HasElement(this string item, Func<XElement, bool> predicate)
 {
     XElement xElement = item.AsXml();
     return HasElement(xElement, predicate);
 }
        /// <summary>
        /// Asserts that the response content type is of the MIME-type 'application/xml' or the specified override.
        /// </summary>
        /// <param name="response">The <see cref="ClientResponse"/> that the assert should be made on.</param>
        /// <param name="assertions">Additional assertions on the XML object.</param>
        /// <param name="contentType">The expected content type.</param>
        /// <returns>An XElement.</returns>
        public static XElement ShouldBeXml(this ClientResponse response, Action<XElement> assertions = null, string contentType = "application/xml")
        {
            response.ShouldHaveContentType(contentType);

            XElement xml;

            try
            {
                xml = response.AsXml();
            }
            catch (Exception exception)
            {
                throw AssertException.Create(response, "Failed to convert response body into XML.", exception);
            }

            assertions.TryInvoke(xml);

            return xml;
        }
        /// <summary>
        /// Asserts that the response content type is of the MIME-type 'application/xml' or the specified override.
        /// </summary>
        /// <param name="response">The <see cref="BrowserResponse"/> that the assert should be made on.</param>
        /// <param name="assertions">Additional assertions on the XML object.</param>
        /// <param name="contentType">The expected content type.</param>
        /// <returns>An XElement.</returns>
        public static XElement ShouldBeXml(this BrowserResponse response, Action<XElement> assertions = null, string contentType = "application/xml")
        {
            response.AssertStatusCode(HttpStatusCode.OK);
            response.AssertContentType(contentType);

            XElement xml;

            try
            {
                xml = response.AsXml();
            }
            catch (Exception exception)
            {
                throw new AssertException("Failed to convert response body into XML.", exception);
            }

            assertions.TryInvoke(xml);

            return xml;
        }