Note that there are some explanatory texts on larger screens.

plurals
  1. POXML::Smart Parser in Perl
    text
    copied!<p>I'm continuing to work out of an outdated <a href="http://books.google.com/books?id=bvY21DGa1OwC&amp;pg=PA549&amp;lpg=PA549&amp;dq=&quot;bioinformatics+programming+using+perl+and+perl+modules&quot;&amp;source=bl&amp;ots=gJZIZVNkpy&amp;sig=AUj2GHbAUDbVlwI4haDYv_rUuv8&amp;hl=en&amp;ei=xb6XS-OOJpK-lAfP6e2UDQ&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=1&amp;ved=0CAgQ6AEwAA#v=onepage&amp;q=%22bioinformatics%20programming%20using%20perl%20and%20perl%20modules%22&amp;f=false" rel="nofollow noreferrer">bioinformatics book</a> and I'm attempting to use the XML::Smart Module. </p> <p>I suspect the module's methods have changed over the course of 6 years and I'm inexperienced with perl to troubleshoot from <a href="http://search.cpan.org/~gmpassos/XML-Smart-1.6.9/lib/XML/Smart.pm#new_(FILE|DATA|URL_,_PARSER_,_OPTIONS)" rel="nofollow noreferrer">cpan source</a>. The commented out code proves the ncbi.gov query functions, I'm having trouble with the 'new' method - it's not parsing the XML. What am I doing wrong? Thanks! </p> <p><strong>Update</strong> Specifically I'm running into trouble with parsing and displaying the Id array: <code>my @Id = $results-&gt;{eSearchResult}{IdList}{Id}{'@'};</code> I'm running this on OSX terminal and I don't see any Ids when I run this script. I am seeing the proper Count. Thanks!</p> <pre><code>#!/usr/local/bin/perl # use lib "/Users/fogonthedowns/myperllib"; # use LWP::Simple; use XML::Smart; use strict; #Set base URL for all eutils my $utils = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils"; my $db = "Pubmed"; my $query ="Cancer+Prostate"; my $retmax = 10; my $esearch = "$utils/esearch.fcgi?" . "db=$db&amp;retmax=$retmax&amp;term="; # my $esearch_result = get($esearch.$query); # print "ESEARCH RESULT: $esearch_result\n"; # print "Using Query: \n$esearch$query\n"; # print "hello world\n"; my $results = XML::Smart-&gt;new($esearch.$query,"XML::Parser"); my $count = $results-&gt;{eSearchResult}{Count}; my @Id = $results-&gt;{eSearchResult}{IdList}{Id}{'@'}; my $all_Id = join("\n", @Id); print "Count = $count\n"; print "$all_Id\n"; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload