Loading ...
Sorry, an error occurred while loading the content.
 

Parsing HTML

Expand Messages
  • edward liddy
    Does anyone have a LB program that can parse the HTML code produced by a MS Word document? This may be helpful to make mass changes and better format the
    Message 1 of 5 , Aug 14, 2008
      Does anyone have a LB program that can parse the HTML code produced by
      a MS Word document? This may be helpful to make mass changes and
      better format the Headers and Footers. Thanks.
    • Stefan Pendl
      ... You can find a demo at http://babek.info/libertybasicfiles/lbnews/nl136/parse.htm You will still have to create a parser that fits your needs, but the demo
      Message 2 of 5 , Aug 15, 2008
        >
        > Does anyone have a LB program that can parse the HTML code
        > produced by
        > a MS Word document? This may be helpful to make mass changes and
        > better format the Headers and Footers. Thanks.
        >

        You can find a demo at http://babek.info/libertybasicfiles/lbnews/nl136/parse.htm
        You will still have to create a parser that fits your needs, but the demo will lead you in the right direction.

        ---
        Stefan Pendl
      • Gordon Sweet
        I am not sure what you mean by parse For example since HTML is just simple ASCII, then as below Notepad can be used to read and modify. it no matter what
        Message 3 of 5 , Aug 15, 2008
          I am not sure what you mean by ' parse ' For example since HTML is just simple ASCII, then as below Notepad can be used to read and modify. it no matter what software has been used to create it. Likewise the Shell Exec routine can be used to activate it.

          I expect you are already aware, as was pointed to me in the other LB Forum, MS Word and FrontPage create a massive amount of unnecessary code, and also always insert meta tabs for the benefit of MS. So you might like to at least change the meta tabs in favour of your site. The code does not appear to get reset by MS, no matter how often you use Word etc again on the code..

          Gordon

          nomainwin

          filedialog "Any","*.*",z$
          if z$ = "" then end
          OP$ = "Notepad.exe " + z$ : run OP$
          ' or say z$ = DefaultDir$ +"\"; "anyfile.ext"
          CALL ShellExecute hWnd, z$
          end


          Sub ShellExecute hWnd, cf$
          parameter = _SW_SHOWNORMAL ' set up for viewing
          lpszOp$ = "open" + Chr$(0) ' "open" or "play" or "print"
          lpszFile$ = cf$ + Chr$(0)
          lpszDir$ = DefaultDir$ + Chr$(0)
          lpszParams$="" + Chr$(0)
          CallDLL #shell32, "ShellExecuteA", hWnd As long,lpszOp$ As ptr,lpszFile$ As ptr,_
          lpszParams$ As ptr,lpszDir$ As ptr,parameter As long, result As long
          End Sub




          [Non-text portions of this message have been removed]
        • Carl Gundel
          Liberty BASIC does not have a built-in HTML parser. If your needs are not too demanding sometimes it is not hard to write your own code to extract what you
          Message 4 of 5 , Aug 15, 2008
            Liberty BASIC does not have a built-in HTML parser. If your needs are not
            too demanding sometimes it is not hard to write your own code to extract
            what you need from a document. In fact sometimes it is better to write your
            own code if you can because HTML is not usually rigorously generated (and
            therefore not valid XML), and so cannot be parsed without a sophisticated
            and "forgiving" algorithm.

            If you're just trying to crack a nut for your own needs, sometimes the
            simplest brute force (ugly hack) gets it done best. ;-)

            -Carl


            > Does anyone have a LB program that can parse the HTML code produced by
            > a MS Word document? This may be helpful to make mass changes and
            > better format the Headers and Footers. Thanks.
          • edward liddy
            Thanks everyone. You gave me everything I needed to know.
            Message 5 of 5 , Aug 15, 2008
              Thanks everyone. You gave me everything I needed to know.
            Your message has been successfully submitted and would be delivered to recipients shortly.