[jdom-interest] url question

Matthias Brauch mb at biss-net.com
Wed Jul 19 13:14:09 PDT 2000


On Wed, 19 Jul 2000 08:58:14 -0500, Mike Danese wrote:

>i'm a java programmer and hava been getting requests for xml functionality
>from
>the content dept. i had no problems getting jdom to manipulte some local xml
>files,
>but now i'm trying to read in a xml doc from a url and failing. i don't see
>to much
>info on this in brets book, maybe because it has more to do with io/streams
>than
>xml programming?? but could someone post an algoritm or sample code for
>reading
>from a url- feeding to parser- then use a stream writer to output part/all
>of a
>dom tree.         thanks from a newbie,,  mike danese   mdanese at mucho.com
>

If you use something like
 java.io.File f = new java.io.File( "c:/tmp/myfile.xml");
 DOMBuilder db = new DOMBuilder();
 Docent doc = db.build( f);
now, an equivalent solution using URL would be
 java.net.URL url = new java.net.URL( "file://localhost/c:/tmp/myfile.xml");
 DOMBuilder db = new DOMBuilder();
 Docent doc = db.build( url);
If this works, you could try loading from the network:
 java.net.URL url = new java.net.URL( "http://www.mucho.com/myfiles/myfile.xml");
 DOMBuilder db = new DOMBuilder();
 Docent doc = db.build( url);

(Just typed this here, no javac has run on this, so please excuse
any typos)

HTH
Matthias

--
=====================================================================
Matthias Brauch
BISS GmbH, Chaukenweg 12, D-26388 Wilhelmshaven, Germany
Phone: +49/4423/9289/0, Fax: +49/4423/9289/99
EMail: mb at biss-net.com
=====================================================================





More information about the jdom-interest mailing list