[racket] sxml parsing

From: michail bulgakov (hofstadtertheman at gmail.com)
Date: Tue Sep 28 17:23:47 EDT 2010


I'm working on a xml parser that inserts data into a sqlite db. The program
looks something like this:

(insert-into-db (get-name doc num) (get-xml doc num))

where get-name looks like this:

(define (get-name doc num)
   ((sxpath "tag/tag2[$i]/tag3/name/text()")
       (sxml:document doc)
       '[(i . num)])))

and get-xml looks like this:

(define (get-xml doc num)
   ((sxpath "tag/tag2[$i]")
       (sxml:document doc)
       '[(i . num)]))

where the xml document looks something like this:

<?generic xml define..>
<some css>

It's suposed to insert the name thats found in every <tag2> and the whole
<tag2> xml string into the database.

This turned out to be realy slow when I have a some xml document with a few
thousand lines of declarations, it parses the document with one line per
second (and yes, I know it's because it opens up the xml file everytime when
it look up something.
But like the newbe that I am I can't come up with any working design to make
it faster. I have looked inte sxml-match and it looks promisin but I don't
realy know how to use it in this project. Does anybody have an idea on how
to do this a bit faster?

Kind regards M.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100928/9e3bcdba/attachment.html>

Posted on the users mailing list.