[plt-scheme] getting data out of xexpr's (xml)

From: Stephen De Gabrielle (stephen at degabrielle.name)
Date: Wed Jan 2 17:51:08 EST 2008


I'm using  (lib "xml.ss" "xml") to read some GraphML  into xexpr's

Once I have loaded it I'm using this sort of (non-working)thing  to
turn it from the xexpr into an alist using for-each and
caddr/cadr/car/cdr etc.

;; populate ;;
      (let* ((data (cdr (caddr xexpr-graph)))) ; get the graph part
         (lambda (row) ;; badly named local for node or edge tag.
           (if (equal? '(edgedefault "undirected") row) (set! edge-directed #t)
               (let* ((row-type (car row))
                      (row-Attributes (if (or (equal? row-type 'node)
                                               (equal? row-type
'edge)) (get-row-Attributes row))))
                 (send alist-collection insert (append (list (list
'class row-type)) (car row-Attributes) (cadr row-Attributes )))))) ;;
add an alist to the collection for each node or edge

 (http://graphml.graphdrawing.org/ socialnet.xml example attached)

My Question is - is there a better way of getting my nodes, edges and
[graph] metadata(directed/undirected) as what I am writing here is
hard to write, hard to read, and doesn't even work.

Should I use  plt-match.ss or  match.ss instead?

Can anyone suggest some code in 'PLT-Full' (v3.99.0.8) that I can
read. It doesn't have to be xml - just xexpr-like - and I am getting
getter at reading code, even without comments :)



Stephen De Gabrielle
s.degabrielle at ucl.ac.uk
Telephone +44 (0)20 7679 5242 (x45242)
Mobile                  079 851 890 45
University College London Interaction Centre
Remax House - 31/32 Alfred Place
London - WC1E 7DP

"There's an old story about the person who wished his computer were as
easy to use as his telephone.  That wish has come true, since I no
longer know how to use my telephone. " -- Bjarne Stroustrup
-------------- next part --------------
A non-text attachment was scrubbed...
Name: socialnet.xml
Type: text/xml
Size: 18698 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20080102/e915efe3/attachment.xml>

Posted on the users mailing list.