title: Read online xml file and parse it
body: <p>I am trying to get comments on youtube videos and parse them using sax. The following is a code that just prints comments given the url. I want to change it to something that takes a url as input from the user and prints the comments. The XML is ONLINE and not saved on local disk, nor do I want to use pre-saved files.</p>
  
  <pre><code>public class ReadXMLFile {
      public static void main(String argv[]) {
          try {
              SAXParserFactory factory = SAXParserFactory.newInstance();
              SAXParser saxParser = factory.newSAXParser();
              DefaultHandler handler = new DefaultHandler() {
                  boolean content=false;
                  int i=0;
                  public void startElement(String uri, String localName,String qName, 
                      Attributes attributes) throws SAXException {
                      if (qName.equalsIgnoreCase("Content")) {
                          content = true;
                          i+=1;
                      }    
                  }
                  public void endElement(String uri, String localName,
                      String qName) throws SAXException { 
  
                  }
                  public void characters(char ch[], int start, int length) throws SAXException {
                      if (content) {
                          System.out.println("Comment " + i +": "+ new String(ch, start, length));
                          content = false;
                      }
                  }
              };
              saxParser.parse("D:\\comment.xml", handler);
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>