[jdom-interest] Problem getting my XML in

Edd Dawson E.J.Dawson at derby.ac.uk
Wed Aug 18 10:33:14 PDT 2004


I am developing some code in Java to access to a publicly accessible
gene database via simple URL's and import the XML into a parser all
using Jdom..

the code is as follows :


package PJB;
* <p>Title: PjbImportCentre </p>
* <p>Description: Class for importing data from Entrez gene</p>
* <p>Copyright: Copyright MitchellConnerSearson Ltd(c) 2004</p>
* <p>Company: MitchellConnerSearson </p>
* @author Edd Dawson
* @version 1.0

import java.net.*;
import java.util.*;
import java.io.*;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
import org.jdom.input.SAXBuilder;

public class PjbImportCentre {

private URL urlObj;

//URL of the webservice which provides data
private final static String EG_URL =

  * Constructor for McsCheckerCentre  Objects.
  * Creates new instance of McsCheckerCentre

 public PjbImportCentre()

 *Gets the xml file for a specific gene uid
 *@param uid String = the uid of the gene you wish to get

 public String getGene(String uid) {

    String xml = "db=gene&dopt=xml&uid=" + uid;

   try {
       //--------open connection to the xml gateway

       URL urlObj = new URL(EG_URL + xml);

       SAXBuilder builder = new SAXBuilder();
       Document doc = null;
       try {
           doc = builder.build(urlObj);
       catch(Exception ex) {
           return "Error on making xml returned SAXable" +

       String geneTrackGeneId =

       return geneTrackGeneId;

   catch(Exception ex) {
       return "error on POST : " + ex.getMessage();



I have a little bit of code to run the class as follows ;


import PJB.*;

class Pjb {

    private void doExample(String search)  {

            PjbImportCentre xmlExample = new PjbImportCentre();

    public static void main(String[] args) {

        Pjb test = new Pjb();



when i run the code as follows :

c:\PJB\java Pjb 4537

i get the following result

"Error on making xml returned SAXable null"

If i pull back the XML from a browser it starts like this :

<?xml version="1.0"?>
<!DOCTYPE Entrezgene PUBLIC "-//NCBI//NCBI Entrezgene/EN"

(for the full document just go to

I am wondering why this is happening, it would appear to be that there
is a problem with the XML being returned if the parser is rejecting it.
Does anyone have any experience of this happening before?


Edd Dawson 

More information about the jdom-interest mailing list