HXELL과 함께 HASKELL에서 RSS 파일을 구문 분석 할 때 태그가 누락 된 경우
문제
Haskell에서 RSS 파일을 구문 분석해야하며 다음과 같은 작업을 수행해야합니다.
atTag tag = deep (isElem >>> hasName tag)
getRSSDetails = atTag "channel" >>>
proc p -> do
fTitle <- gotoAndTake "title" -< p
fLink <- gotoAndTake "link" -< p
fDescription <- gotoAndTake "description" -< p
fLanguage <- gotoAndTake "language" -< p
fGenerator <- gotoAndTake "generator" -< p
fCopyright <- gotoAndTake "copyright" -< p
fWebMaster <- gotoAndTake "webMaster" -< p
fLastBuildDate <- gotoAndTake "lastBuildDate" -< p
where gotoAndTake a = (getChildren >>>
isElem >>>
hasName a >>>
getChildren >>>
getText)
.
내 문제는 하나의 태그가 누락 된 경우, 빈 목록을 얻는 것보다 RSS 파일에서 "lastbuilldate"라고 말하지 만, 해당 항목을 ""로 바꾸기를 원합니다.
어떻게 할 수 있습니까 ??고마워,
main = do
rssFeeds <- runX (parseRSS "rss.xml" >>> getRSSDetails)
print rssFeeds
.
edit1 : 추가로 해결됨
orElse
(Constra "")가 GoToAndtake A ...
해결책
첨가하여
해결됨
orElse (constA "")
.
의 끝에서
where gotoAndTake a = (getChildren >>>
isElem >>>
hasName a >>>
getChildren >>>
getText)
. 제휴하지 않습니다 StackOverflow