XML-Pull: Pull-style XML parsing for PLT Scheme

xml-pull is meant to be used only if we're dealing with really huge XML files; if we're dealing with a small XML file, then the regular sxml library will probably be a better choice. If we're handling really huge XML files, xml-pull may be helpful.

To use this in PLT Scheme, it's probably easiest to grab it from PLaneT. Here's an example:

(module text-xml-pull mzscheme

  ;; This test script prints out all the story items in Lambda the Ultimate.
  (require (planet "xml-pull.ss" ("dyoo" "xml-pull.plt" 1 0))
           (lib "pretty.ss")
           (lib "url.ss" "net"))

  (define rdf
    (get-pure-port (string->url "http://lambda-the-ultimate.org/rss.xml")))
  (define my-taffy (start-xml-pull rdf))
  ;; Print out all the RDF items till we exhaust the taffy.
  (let loop ([morsel (pull-morsel my-taffy)])
      [(exhausted? morsel) (void)]
      [(and (start-element? morsel)
            (equal? (start-element-name morsel) 
       (pretty-print (pull-sexp my-taffy))
       (loop (pull-morsel my-taffy))]
       (loop (pull-morsel my-taffy))])))

(Thanks to Paste Scheme for making the example code above look pretty.)

Back to PLT.