この質問から問題を続けています。mb
タスクは、特定の値を持つノードを検索し、要素内の にmodel
attribute
一致しなかったノードを除外することです。フィルタリングしたら、 から値のリストを取得する必要があります。私はいくつかの進歩を遂げました。と照合して、属性の値を取得できます。value
attribute
dmiattr
rev
attribute
model
attribute
rev
しかし、私は子にドリルダウンするのに苦労していdmiattr
ます。私はほとんどすべての正しい機能を持っていると思いますが、おそらく正しいコンビネーターではありません。そして、私のコードのロジックもおかしくなっているのかもしれません。どこが間違っているのかわかりません。フィードバックが承認されました。
import Text.XML
import Text.XML.Cursor
import qualified Data.Text as T
getProfiles :: AdviseConf -> IO () -- AdviseResult
getProfiles (AdviseConf model mb) = do
doc <- Text.XML.readFile def xmlFile
let cursor = fromDocument doc
_ <- Prelude.writeFile "test.txt" $
show $
cursor $//
check findNode &.// -- &//
attributeIs "model" "460" &.//
check findMB &.//
followingSibling &.//
attributeIs "value" "GF615M-P33 (MS-7597)" &.//
attribute "rev"
return ()
findNode :: Cursor -> Bool
findNode c = case (attribute "rev" c) of
[] -> False
otherwise -> True
findMB :: Cursor -> Bool
findMB c = case ( attribute "value" c) of
[] -> False
otherwise -> True