2

例を挙げる:

<pous>
  <pou>
    <interface>
      ...
    </interface>
    <body>
      <FBD>
        ...
      </FBD>
    </body>
  </pou>
  <pou>
    <interface>
      ...
    </interface>
    <body>
      <SFC>
        ...
      </SFC>
    </body>
  </pou>
</pous>

関数 atTag を使用してすべての「pou」を取得する方法を知っています。

atTag:: (ArrowXml a) => String -> a XmlTree XmlTree
atTag tag = deep (isElem >>> hasName tag)

しかし、SFCタグで「pou」だけを抽出するにはどうすればいいですか?それを行うためのきれいな方法はありますか?

前もって感謝します!

4

2 に答える 2

1

filterAこの例に使用したい

application
    = processChildren
    $ getChildren                    -- Gets the children of "pous"
    >>> filterA hasSFC
    where hasSFC =  hasName "pou"    -- Include all "pou" elements
                >>> getChildren      -- that have children
                >>> getChildren      -- that have children
                >>> hasName "SFC"    -- that have a "SFC" element

main = do
    runX $
        readDocument [] "input.xml" >>>
        application                 >>>
        writeDocument [withIndent yes] "output.xml"
于 2015-04-24T14:29:21.873 に答える