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

From: Robby Findler (robby at cs.uchicago.edu)
Date: Wed Jan 2 17:54:19 EST 2008

I think you want:

(require (lib "xml.ss" "xml"))
(xml->xexpr (read-xml/element (open-input-string "<a><b>cdef</b></a>")))

which produces

'(a () (b () "cdef"))

hth,
Robby

On Jan 2, 2008 4:51 PM, Stephen De Gabrielle <stephen at degabrielle.name> wrote:
> Hi,
>
> 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
>         (for-each
>          (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
>          data))
>
>  (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 :)
>
>
> Cheers,
>
> Stephen
>
>
>
> --
> Stephen De Gabrielle
> s.degabrielle at ucl.ac.uk
> Telephone +44 (0)20 7679 5242 (x45242)
> Mobile                  079 851 890 45
> http://www.uclic.ucl.ac.uk/annb/MaSI.html
> 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
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.