[LON-CAPA-cvs] cvs: nsdl / lonsql

www lon-capa-cvs@mail.lon-capa.org
Thu, 17 Nov 2005 22:52:01 -0000


www		Thu Nov 17 17:52:01 2005 EDT

  Modified files:              
    /nsdl	lonsql 
  Log:
  Starting to parse output
  
  
Index: nsdl/lonsql
diff -u nsdl/lonsql:1.3 nsdl/lonsql:1.4
--- nsdl/lonsql:1.3	Thu Nov 17 17:34:49 2005
+++ nsdl/lonsql	Thu Nov 17 17:51:59 2005
@@ -3,7 +3,7 @@
 # The LearningOnline Network
 # lonsql - LON TCP-NSDL Query Handler.
 #
-# $Id: lonsql,v 1.3 2005/11/17 22:34:49 www Exp $
+# $Id: lonsql,v 1.4 2005/11/17 22:51:59 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -856,8 +856,33 @@
     my $url='http://search.nsdl.org?verb=Search&s=0&n=500&q='.$keyword;
     my $ua=new LWP::UserAgent;
     my $response=$ua->get($url);
-
-    return [];
+    my $parser=HTML::LCParser->new(\$response->content);
+    my %result=();
+    my $is=();
+    my $cont='';
+    my $array=[];
+    my $token;
+    while ($token=$parser->get_token) {
+	if ($token->[0] eq 'T') {
+	    $cont.=$token->[1];
+	} elsif ($token->[0] eq 'S') {
+	    if ($token->[1] eq 'record') {
+		%result=();
+	    } elsif ($token->[1]=/^dc\:/) {
+		$is=$token->[1];
+		$cont='';
+	    }
+	} elsif ($token->[0] eq 'E') {
+	    if ($token->[1] eq 'record') {
+#
+# Now store it away
+#
+	    } elsif ($token->[1]=/^dc\:/) {
+		$result{$is}=$cont;
+	    }
+	}
+    }
+    return $array;
 }
 
 =pod