parseAnnotationsFromXML xmlString = do
        parseResult <- mkParseResult xmlString
        let contentRoot = mkContentRoot parseResult
        sConfidence <- fmap read $ parseConfidence contentRoot
        sSupport <- fmap read $ parseSupport contentRoot
        sResources <- parseResources contentRoot
        return $ SpotlightResponse sConfidence sSupport sResources
    where
        rootElem contentRoot = contentElem contentRoot
        rootAttrs = map stringsForAttValues . attrs . rootElem
        parseConfidence = lookup' (N "confidence") . rootAttrs
        parseSupport = lookup' (N "support") . rootAttrs
        parseResources = mapM parseResource . resources
        resources = keep /> tag "Resources" /> tag "Resource"
        parseResource content = do
            rURI <- parseURI' =<< resourceAttr "URI"
            rSupport <- fmap read $ resourceAttr "support"
            rTypes <- fmap extractResourceTypes $ resourceAttr "types"
            rSurfaceForm <- resourceAttr "surfaceForm"
            rOffset <- fmap read $ resourceAttr "offset"
            rSimScore <- fmap read $ resourceAttr "similarityScore"
            rPercentSecondRank <- fmap read $
                resourceAttr "percentageOfSecondRank"
            return $ SpotlightResource rURI rSupport rTypes rSurfaceForm
                rOffset rSimScore rPercentSecondRank
            where
                resourceAttrs = map stringsForAttValues $
                    attrs $ contentElem content
                resourceAttr attr = lookup' (N attr) resourceAttrs
parseAnnotationsFromXML xmlString = do
        parseResult <- mkParseResult xmlString
        let contentRoot = mkContentRoot parseResult
        sConfidence <- fmap read $ parseConfidence contentRoot
        sSupport <- fmap read $ parseSupport contentRoot
        sResources <- parseResources contentRoot
        return $ SpotlightResponse sConfidence sSupport sResources
    where
        rootElem contentRoot = contentElem contentRoot
        rootAttrs = map stringsForAttValues . attrs . rootElem
        parseConfidence = lookup' (N "confidence") . rootAttrs
        parseSupport = lookup' (N "support") . rootAttrs
        parseResources = mapM parseResource . resources
        resources = keep /> tag "Resources" /> tag "Resource"
        parseResource content = do
            rURI <- parseURI' =<< resourceAttr "URI"
            rSupport <- fmap read $ resourceAttr "support"
            rTypes <- fmap extractResourceTypes $ resourceAttr "types"
            rSurfaceForm <- resourceAttr "surfaceForm"
            rOffset <- fmap read $ resourceAttr "offset"
            rSimScore <- fmap read $ resourceAttr "similarityScore"
            rPercentSecondRank <- fmap read $
                resourceAttr "percentageOfSecondRank"
            return $ SpotlightResource rURI rSupport rTypes rSurfaceForm
                rOffset rSimScore rPercentSecondRank
            where
                resourceAttrs = map stringsForAttValues $
                    attrs $ contentElem content
                resourceAttr attr = lookup' (N attr) resourceAttrs
parseAnnotationsFromXML xmlString = do
        parseResult <- mkParseResult xmlString
        let contentRoot = mkContentRoot parseResult
        sConfidence <- fmap read $ parseConfidence contentRoot
        sSupport <- fmap read $ parseSupport contentRoot
        sResources <- parseResources contentRoot
        return $ SpotlightResponse sConfidence sSupport sResources
    where
        rootElem contentRoot = contentElem contentRoot
        rootAttrs = map stringsForAttValues . attrs . rootElem
        parseConfidence = lookup' (N "confidence") . rootAttrs
        parseSupport = lookup' (N "support") . rootAttrs
        parseResources = mapM parseResource . resources
        resources = keep /> tag "Resources" /> tag "Resource"
        parseResource content = do
            rURI <- parseURI' =<< resourceAttr "URI"
            rSupport <- fmap read $ resourceAttr "support"
            rTypes <- fmap extractResourceTypes $ resourceAttr "types"
            rSurfaceForm <- resourceAttr "surfaceForm"
            rOffset <- fmap read $ resourceAttr "offset"
            rSimScore <- fmap read $ resourceAttr "similarityScore"
            rPercentSecondRank <- fmap read $
                resourceAttr "percentageOfSecondRank"
            return $ SpotlightResource rURI rSupport rTypes rSurfaceForm
                rOffset rSimScore rPercentSecondRank
            where
                resourceAttrs = map stringsForAttValues $
                    attrs $ contentElem content
                resourceAttr attr = lookup' (N attr) resourceAttrs