This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 107
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: 12759
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retrieve XML data from URL
 
Similar Threads
Unmarshall with JAXB Error
XML over http
Trying to iterate an ArrayList of Beans
How to read from XSD generated database and put that data into XML file.
Loading problem with t:inputFileUpload