wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes retrieve XML data from URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "retrieve XML data from URL" Watch "retrieve XML data from URL" New topic
Author

retrieve XML data from URL

Steve Jiang
Ranch Hand

Joined: May 17, 2004
Posts: 106
is there simple way to retrieve XML data from a existing URL directly? after I use getDocumentElement to get element from URL, could I output the contents of element in a simple way without parse the subnodes? so I can output the contents of URL in a general way without the concern for the inside content of XML?

Thanks,

Steve
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
A URL is not an XML document so I assume you mean to open a URLConnection to a XML document and read it. See java.net.URLConnection and HttpURLConnection. Just open the connection and getInputStream.

If all you want is to echo the contents, just read the InputStream and write to whatever suits your fancy.

If you need to do something with the XML, you can just feed the InputStream to a DocumentBuilder to get a DOM.
If you just want the content text without the tags, use an SAX parser.
Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retrieve XML data from URL
 
Similar Threads
XML over http
How to read from XSD generated database and put that data into XML file.
Loading problem with t:inputFileUpload
Trying to iterate an ArrayList of Beans
Unmarshall with JAXB Error