Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    XMLTools.selectNodes()

    I am using the following code to fetch a record from pubmed:

    Code:
    var url = "http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&rettype=xml&id=22028782";
    XMLTools.loadXML(url, "editor.parsePubmedXML(xmlDoc, xmlText)");
    (For your convenience I put in a specific pubmedid)

    The following code tries to parse the xml:

    Code:
        parsePubmedXML: function(xmlDoc, xmlText) {
        	if (xmlDoc == null) {
        		return;
        	}
        	var nodes = XMLTools.selectNodes(xmlDoc, "//Article");
        	isc.say("found " + nodes.length + " nodes");
        }
    This never finds the <Article> node (there is 1 Article element returned). You can look at the returned xml easily enough by cutting and pasting the url into your browser.

    I must be missing something obvious.

    Thanks,
    pf

    #2
    It appears that this link is hitting a url which returns a page of escaped XML (formatted for viewing in the browser as a web page).
    If you copy and paste the URL and right click / "view source" you can see this.

    This is why the xmlDoc in the callback is null.

    We are not experts in the pubmed web services implementation but it looks like your parameters may be incorrect -- you may need to use 'retmode=xml' rather than 'rettype=xml'?

    Comment

    Working...
    X