HXTを使用してods(libreofficeスプレッドシート)ファイルを解析しようとしていますが、問題が発生しています。スプレッドシートでは、行には多くのセル(すべて「cell」という名前)があり、スプレッドシートには多くの行(すべて名前row)があります。セルのテキストを取得しようとすると、コードがそれをすべて混ぜ合わせてしまい、行で区切られていないセルの束全体になってしまいます...
以下を解析しようとすると:
<spreadsheet>
<row>
<cell> <p>ABC</p> </cell>
<cell> <p>DEF</p> </cell>
<cell> <p>GHI</p> </cell>
</row>
<row>
<cell> <p>abc</p> </cell>
<cell> <p>def</p> </cell>
<cell> <p>ghi</p> </cell>
</row>
<row>
<cell> <p>123</p> </cell>
<cell> <p>456</p> </cell>
<cell> <p>789</p> </cell>
</row>
</spreadsheet>
コードで:
import Text.XML.HXT.Core
play arg = do { results <- runX (processor arg) ; print results }
atTag x = getChildren >>> isElem >>> hasName x
processor filename =
readDocument [withValidate no] filename >>>
atTag "spreadsheet" >>>
atTag "row" >>>
atTag "cell" >>>
atTag "p" >>>
getChildren >>> getText
それは[ABC、DEF、GHI、abc、def、ghi、123、456、789]を与えますが、私が欲しかったのは[[ABC、DEF、GHI]、[abc、def、ghi]、[123、456、789]でした]。
私は何が間違っているのですか?