| 
    1module Main 
   2where 
   3  
   4import Text.XML.HXT.Arrow 
   5import System.Environment 
   6  
   7main :: IO () 
   8main 
   9    = do 
  10      [src, dst, showTree] <- getArgs 
  11      runX ( readDocument 
  12               [ (a_parse_html, v_1) 
  13               , (a_issue_warnings, v_0) 
  14               ] src 
  15             >>> 
  16             processChildren 
  17               ( processDocumentRootElement 
  18                 `when` 
  19                 isElem 
  20               ) 
  21             >>> 
  22             writeDocument 
  23               [ (a_indent, v_1) 
  24               , (a_show_tree, showTree) 
  25               ] dst 
  26           ) 
  27      return () 
  28 
  29processDocumentRootElement      :: ArrowXml a => a XmlTree XmlTree 
  30processDocumentRootElement 
  31    = selem "the-plain-text" 
  32      [ hasName "html" 
  33        >>> 
  34        getChildren 
  35        >>> 
  36        hasName "body" 
  37        >>> 
  38        getChildren 
  39        >>> 
  40        deep ( hasName "div" 
  41               >>> 
  42               hasAttrValue "id" (== "content") 
  43             ) 
  44        >>> 
  45        getChildren 
  46        >>> 
  47        deep ( hasName "td" 
  48               >>> 
  49               hasAttrValue "valign" (== "top") 
  50               >>> 
  51               hasAttrValue "width" (== "75%") 
  52             ) 
  53        >>> 
  54        getChildren 
  55        >>> 
  56        deep isText 
  57      ] 
 | 
    
| Letzte Änderung: 27.03.2015 | © Prof. Dr. Uwe Schmidt |