File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieve XML data from URL

 
Steve Jiang
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic