Can someone post apple script code to tell Safari to refresh every 5 min?

Can someone post apple script code to tell Safari to refresh every 5 min?
thanx in advance!

save the script as an application and checkmark the "Stay Open" box
-- start script
on idle
tell application "Safari"
activate
set doc_url to URL of document 1
open location doc_url
end tell
return 15 --<change the number 15 to the number of seconds you want between each refresh
end idle
-- end script
<br>
Mac OS X (10.4.7)

Similar Messages

  • Can someone at Apple please help me with iPhone 4s battery life?

    I bought two iphone 4s 16gig's the day they were released from Sprint and am having horrible battery life. I love the phone and its features, but I have tried everything I have found in the discussion groups and in other forums online and am still getting terrible battery life from the 4s's.
    For example, I charged my 4s when I got home last night and then once it was at 100% charge at bedtime, took it off my charger in order to use that same charger to charge my ipad overnight. This morning, the fully charged 4s had dropped to 45% battery life...without ANY use whatsover overnight...! I just asked my wife how her 4s is doing today and hers is down to 63% since this morning with very, very little usage. (She hardly ever uses any of the data features, etc., only makes phone calls).
    Something really weird also happened to the battery life yesterday while I was flying home from Venezuela. I had charged my phone overnight and did not use it at all on the way to the airport, then turned it off on the plane from Maracaibo to Miami. When I arrived in Miami, I turned it on, checked my email, sent a few text messages and also some Heytell messages during my 1:45 minute layover before turning it off before getting on the plane. Our flight was delayed due to mechanical problems and I turned the phone one in order to show my seat mates how Siri works. When I turned it on, I was shocked to find the battery percentage had dropped to sixty some percent...!
    I left T-Mobile after 8+ years as a very satisfied customer specifically to get the new 4s. Was running jailbroken 3gs on T-Mobile without any problem and much, much better battery life. Needless to say, I am very unhappy with what we are dealing with. I wish someone from Apple would at least tell us what is going on or simply replace our phones if it is a hardware issue.

    You need to check out some of the other threads on battery issues (but not the very long one) in this forum.  There are a lot of suggestions from users who seems to solved the problem.
    But you won't get any Apple input here, as this is a user-to-user forum and Apple usually doesn't respond to out posts.

  • Can I use Apple Script to press a button?

    Is there some way I can create an Apple Script to run and press a button in another application, or create a "plug-in" type script for the program to make the button into a something that can be used by a keyboard shortcut?
    I ask because I have an application that I can use to operate my digital camera, however, the button that Auto-Focuses then Shoots a photo does not have a keyboard shortcut. This is a problem because I also have the App "Snatch" on my iPhone, and, long story, short, I discovered I could use Snatch on my laptop on an Ad-Hoc network from about 1,000 feet away, maybe more. If I could find a way of making the "AF and Shoot" button into a keyboard shortcut, or create a script that could be triggered by a keyboard shortcut to press the button, I could use Snatch to control my camera remotely, far better then any part I would by from Nikon, or a third-party (Trust me, I have used a lot of them, and this method beats them all, save for the fact that I can't use bulb.)
    Anyway, thanks for any input, if any.

    Even if an application is not scriptable, you can generally use [GUI Scripting|http://www.macosxautomation.com/applescript/uiscripting/index.html] to press a button. For example, using Canon's RemoteCapture DC software, the script below will press the "Release" button of the main window:
    tell application "RemoteCapture DC" to activate
    tell application "System Events"
    tell process "RemoteCapture DC"
    click button 4 of window "RemoteCapture DC"
    end tell
    end tell
    If you then put the above script in the AppleScript menu in the menu bar, you should be able to use a third party application, like Quicksilver, to assign a keyboard shortcut to it.
    Message was edited by: Pierre L.

  • My account is locked, i cant remember my security question, and I accidentally entered my itunes card in here instead of my other account, so can someone from apple help me out and fix my account

    my account is locked, i cant remember my security question, and I accidentally entered my itunes card in here instead of my other account, so can someone from apple help me out and fix my account (and no, i dont have any rescue email address or whatsoever)
    please help me because i dont to waste money for nothing

    Alternatives for Help Resetting Security Questions and/or Rescue Mail
         1. If you have a valid rescue email address, then use this procedure:
             Rescue email address and how to reset Apple ID security questions.
         2. Fill out and submit this form. Select the topic, Account Security. You must
             have a Rescue Email to use this option.
         3. This is the only option if you do not already have a valid Rescue Email.
             These are telephone numbers for contacting Apple Support in your country.
             Apple ID- Contacting Apple for help with Apple ID account security. Select
             the appropriate country and call. Ask to speak to the Account Security Team.
         4. Account security issues almost always require you to speak directly to an
             Apple representative to securely establish your identity as the account holder.
             You can set it up so that Apple calls you, either immediately or at a time
             convenient to you.
                1. Go to www.apple.com/support.
                2. Choose Contact Support and click Contact Us.
                3. Choose Other Apple ID Topics and choose the appropriate topic for
                    your issue.
                4. Follow the onscreen instructions.
             Note: If you have already forgotten your security questions, then you cannot
             set up a rescue email address in order to reset them. You must set up
             the rescue email address beforehand.
    Your Apple ID: Manage My Apple ID.
                            Apple ID- All about Apple ID security questions.

  • Can someone from Apple confirm sync issue.....

    Q. Can someone from Apple please confirm that they are aware of some sync issues that is causing itunes 9.2.0.61 to crash???
    Q. Can we expect a new version of Itunes any time soon?
    I have iTunes running on a windows 7 machine & two ipod touches (Both 3G running the power draining IOS4). My ipod touch Sync's OK however my partner (who uses the same computer and software) has Itunes 'stop & quit' when trying to sync her music. The program quits out at the same point when it reaches the same music track. I did start removing the tracks that has the problem but it was getting to the point that I was removing a lot of stuff - stuff that plays OK in the iTunes software and previously sync'ed OK with the old software.
    The most annoying thing is that Apple (as far as I have seen) isn’t even acknowledging any kind of problem. The same could be said of the ridiculous battery consumption under IOS4.

    Ianuk01 wrote:
    I find it quite bizarre that Apple affiliate themselves to a support forum and then have nothing to do with it? Everyone who logs into this support website does so with their Apple I.D, so why the he'll does this forum even exist if Apple have no technical input or can't be bothered to confirm or deny that they are aware of a problem. It's lazy and poor customer support....
    Well, Apple's affiliated with it because it's their site, and about their products. That doesn't necessarily mean that they have to be a part of User Discussions. (after all, at least they aren't false advertising right?)
    I mean think about it, Facebook is affiliated with your Facebook profile right? Does that mean that the Facebook owners are going to meddle with your personal affairs? Probably not.
    I wouldn't consider these forums as CUSTOMER support, more as PEER support. Apple provides customer support other ways, by FAQs, Apple Stores, and Contacting Them. I'm not saying one way whether Apple is good or bad with this, I am simply stating they offer other customer support options.

  • I have an Iphone 4 iOS 6.1.3 and have read that it is capable to receive the Weather Emergency Alert system. I have also been told that it will not. This is confusing. Can someone at Apple clarify. If it doe not work on this phone is a download available?

    I have an Iphone 4 iOS 6.1.3 and have read that it is capable of receiving the Weather Emergency Alert system. I have also been told that it will not. There is no option in Settings / Notifications. This is confusing. Can someone at Apple clarify? If it does not work on this phone is a download available?

    Apple usually doesn't participate here, we're just users.  Have you done a search for an app for Weather Emergency Alert in the app store?  It certainly doesn't come built-in in the iphone.

  • Action Script 3, can someone spot where my code is wrong?

    I want to have my characters controlled separately, with 'FireBoy' moving using the left, up and right keys and with 'WaterGirl' moving with the a, w and d keys. However upon editing my code somehow WaterGirl now moves with the right key instead of the d key. Please can someone spot where I have made a mistake and advise me on how to resolve the problem.
    My code for main.as is:
    package
      import flash.display.Bitmap;
      import flash.display.Sprite;
      import flash.events.Event;
      import flash.events.KeyboardEvent;
      import flash.events.MouseEvent;
      * @author Harry
      public class Main extends Sprite
      private var leftDown:Boolean = false;
      private var rightDown:Boolean = false;
      private var aDown:Boolean = false;
      private var dDown:Boolean = false;
      private var FireBoy:Hero = new Hero();
      public var StartButton:Go;
      public var WaterGirl:Female = new Female();
      public var Door1:Firedoor;
      public var Door2:Waterdoor;
      public var Fire:Lava;
      public var Water:Blue;
      public var Green:Gem;
      public function Main():void
      if (stage) init();
      else addEventListener(Event.ADDED_TO_STAGE, init);
      public function init(e:Event = null):void
      StartButton = new Go();
      StartButton.x = 100;
      StartButton.y = 5;
      addChild(StartButton);
      StartButton.addEventListener(MouseEvent.CLICK, startgame);
      private function startgame(e:Event = null):void
      removeEventListener(Event.ADDED_TO_STAGE, init);
      // entry point
      removeChild(StartButton);
      FireBoy.y = 495;
      addChild(FireBoy);
      stage.addEventListener(Event.ENTER_FRAME, HerocheckStuff);
      stage.addEventListener(KeyboardEvent.KEY_DOWN, HerokeysDown);
      stage.addEventListener(KeyboardEvent.KEY_UP, HerokeysUp);
      WaterGirl.x = 70;
      WaterGirl.y = 495;
      addChild(WaterGirl);
      stage.addEventListener(Event.ENTER_FRAME, FemalecheckStuff);
      stage.addEventListener(KeyboardEvent.KEY_DOWN, FemalekeysDown);
      stage.addEventListener(KeyboardEvent.KEY_UP, FemalekeysUp);
      Door1 = new Firedoor();
      stage.addChild(Door1);
      Door1.x = 5;
      Door1.y = 62;
      Door2 = new Waterdoor();
      stage.addChild(Door2);
      Door2.x = 100;
      Door2.y = 62;
      Fire = new Lava();
      stage.addChild(Fire);
      Fire.x = 160;
      Fire.y = 570;
      Water = new Blue();
      stage.addChild(Water);
      Water.x = 350;
      Water.y = 160;
      Green = new Gem()
      stage.addChild(Green);
      Green.x = 500;
      Green.y = 100;
      graphics.beginFill(0x804000, 1);
      graphics.drawRect(0, 0, 800, 40);
      graphics.endFill();
      graphics.beginFill(0x804000, 1);
      graphics.drawRect(0, 170, 600, 40);
      graphics.endFill();
      graphics.beginFill(0x804000, 1);
      graphics.moveTo(800, 200);
      graphics.lineTo(800, 700);
      graphics.lineTo(400, 700);
      graphics.lineTo(100, 700);
      graphics.endFill();
      graphics.beginFill(0x804000, 1);
      graphics.drawRect(0, 580, 800, 40);
      graphics.endFill();
      public function Collision():void
      if (WaterGirl.hitTestObject(Fire))
      WaterGirl.x = 70;
      WaterGirl.y = 495;
      if (FireBoy.hitTestObject(Water))
      FireBoy.x = 15;
      FireBoy.y = 495;
      public function HerocheckStuff(e:Event):void
      if (leftDown)
      FireBoy.x -= 5;
      if (rightDown)
      FireBoy.x += 5;
      FireBoy.adjust();
      Collision();
      Check_Border();
      public function HerokeysDown(e:KeyboardEvent):void
      if (e.keyCode == 37)
      leftDown = true;
      if (e.keyCode == 39)
      rightDown = true;
      if (e.keyCode == 38)
      FireBoy.grav = -15;
      Collision();
      Check_Border();
      public function HerokeysUp(e:KeyboardEvent):void
      if (e.keyCode == 37)
      leftDown = false;
      if (e.keyCode == 39)
      rightDown = false;
      public function FemalecheckStuff(e:Event):void
      if (aDown)
      WaterGirl.x -= 5;
      if (rightDown)
      WaterGirl.x += 5;
      WaterGirl.adjust2();
      Collision();
      Check_Border();
      public function FemalekeysDown(e:KeyboardEvent):void
      if (e.keyCode == 65)
      aDown = true;
      if (e.keyCode == 68)
      dDown = true;
      if (e.keyCode == 87)
      WaterGirl.grav = -15;
      Collision();
      Check_Border();
      public function FemalekeysUp(e:KeyboardEvent):void
      if (e.keyCode == 65)
      aDown = false;
      if (e.keyCode == 68)
      dDown = false;
      public function Check_Border():void
      if (FireBoy.x <= 0)
      FireBoy.x = 0;
      else if (FireBoy.x > 750)
      FireBoy.x = 750;
      if (WaterGirl.x <= 0)
      WaterGirl.x = 0;
      else if (WaterGirl.x > 750)
      WaterGirl.x = 750;
    My code for Hero.as (FireBoy) is:
    package 
      import flash.display.Bitmap;
      import flash.display.Sprite;
      public class Hero extends Sprite
      [Embed(source="../assets/FireBoy.jpg")]
      private static const FireBoy:Class;
      private var FireBoy:Bitmap;
      public var grav:int = 0;
      public var floor:int = 535;
      public function Hero()
      FireBoy = new Hero.FireBoy();
      scaleX = 0.1;
      scaleY = 0.1;
      addChild(FireBoy);
      public function adjust():void
      this.y += grav;
      if(this.y+this.height/2<floor)
      grav++;
      else
      grav = 0;
      this.y = floor - this.height / 2;
      if (this.x - this.width / 2 < 0)
      this.x = this.width / 2;
      if (this.x + this.width / 2 > 800)
      this.x = 800 - this.width / 2;
    And finally my code for Female.as (WaterGirl) is:
    package 
      import flash.display.Bitmap;
      import flash.display.Sprite;
      * @author Harry
      public class Female extends Sprite
      [Embed(source="../assets/WaterGirl.png")]
      private static const WaterGirl:Class;
      private var WaterGirl:Bitmap;
      public var grav:int = 0;
      public var floor:int = 535;
      public function Female()
      WaterGirl = new Female.WaterGirl();
      scaleX = 0.1;
      scaleY = 0.1;
      addChild(WaterGirl);
      public function adjust2():void
      this.y += grav;
      if(this.y+this.height/2<floor)
      grav++;
      else
      grav = 0;
      this.y = floor - this.height / 2;
      if (this.x - this.width / 2 < 0)
      this.x = this.width / 2;
      if (this.x + this.width / 2 > 800)
      this.x = 800 - this.width / 2;

    You should make use of the trace function to troubleshoot your processing.  Put traces in the different movement function conditionals to see which is being used under which circumstances.  You might consider putting the movement code into one function since they all execute when you process a keyboard event anyways.

  • Help with Apple Script Code

    Hi,
    I found this Apple script online and here's how it works:
    tell application "QuickTime Player"
    activate
    try
    if not (exists document 1) then display dialog "Please open a QuickTime movie." buttons {"Cancel"} default button 1 with icon 1
    set thefile to (choose file name)
    save document 1 in thefile
    close document 1
    end try
    end tell
    +I run the Apple script+
    *1. It prompts me to open a movie file in Quicktime*
    +I open a movie in Quicktime+
    *2. It prompts me for an name and directory to save the new file in*
    +I enter a name and directory+
    *3. It saves a new reference movie in said directory with said name*
    This is useful if I want to customize every file, but unfortunately, I just want to mass create reference movies for a whole bunch of files.
    What I am looking for is for an Apple script that is a drag and drop application, so I can drop say 100 movie files or so, and have the Apple script create reference movie files with the same name and in the same directory automatically with no prompts.
    Since I am unfamiliar with Apple script I was wondering if someone would be able to edit my existing script to do what I want.
    Thanks so much for your help!

    Use Automator. It's great for repetitious tasks (like the one you've described), and it's very user-friendly. Open Automator, create a new workflow that executes the action you want, and you can apply that action to the resources you wish to edit.
    Good resource here:
    http://bit.ly/

  • Need someone to chek my code n tell me if the asserts work. Please!!

    Hi , its importante that someone could help me on my code.
    the code is the greatest common divisor ( Maximo divisor comum)
    Well , the code is all right but i can't run it with the asserts , im using Eclipse 3.1 , the level of compilation is 1.3 .
    It says that ignores de asserts but when i compile it gives me error on assert expression.
    I would like to someone could test this code in another JAva editor like XEmacs or JBuilder ,anything that works with asserts and accept them.
    Someone working with linux could test this too?
    Just wanna see if the assertions are right , because i can't run the program with them in the eclipse. :S
    Its importante, help me please.
    Code:
    import pt.iscte.io.*;
    public class gCommonDivisor {
    public static void main(String[] args){
          assert 0 < n : n;     //  <--  THERE THEY ARE  : (
          assert 0 < d : d;  // n is the numerator and d is the denomi.
    System.out.println("Insira valor do numerador: ");
              int n = Teclado.intLido();
              System.out.println("Insira valor do denominador: ");
              int d = Teclado.intLido();
              int r = mdc( n, d); // modulo para o maximo divisor comum
              int den = denominador(r , d); // modulo para denominador simplificado
              int num = numerador(r, n); // modulo para numerador simplificado
              // Output do Maximo divisor comum e da frac�ao reduzida
              System.out.println("Maximo divisor comum entre "+ n +" e "+ d +" � "+ r);
              System.out.print("Frac��o reduzida de "+ n +"/"+ d +" = "+ num +"/"+ den);
               * @pre V.
               * @post gcd = maximo divisor comum
              static int mdc(int n, int d){
              int gcd = 1;
              int k =1;
              while (k <= n && k <= d) {
                   if (n % k == 0 && d % k == 0)
                        gcd =k;
                   k++;
                   return gcd;
              // numerador simplificado
              static int numerador(int r , int n ) {
              int numerador = n / r;
              return numerador;
              // denominador simplificado
              static int denominador(int r , int d ) {
              int denominador = d / r;
              return denominador;
    } Thank you so much .
    Please help me!
    Sorry about the language of the code. but dont worry about it, the code works fine without those two asserts after the main.
    kind regards,
    Josh

    wow i forgot to say that u just need to change the
    expression to read the input from the console.
    U dont have the iscte_io.jar
    change int n = Teclado.intLido();
    and int m = Teclado.intLido();
    cuz u don't have the Teclado( Keyboard) i had to import pt.iscte.io.Teclado;
    to read the input given by the user.
    thks

  • Can someone post a chart showing what adapter works with each device?. I have one of each and I am getting confused.

    Can someone please post a chart of what adapter works with the different devices? I have a MacBook air, I-pod, I-pad, and I-phone 4. I am getting my adapters mixed up.

    Macbook: https://www.powerbookmedic.com/xcart1/images/D/macbook-air-adapter.gif
    All iDevices until 2012 (excepting 3rd generation iPad) used the 30-pin connector: http://igyaan.in/wp-content/uploads/2012/01/idevice-30-pin-connector2.png
    Newer iDevices: iPhone 5, iPad 4th generation, iPad Mini, and iPod touch 5th generation use the Lightning connector. If you do not have one of these devices, it does NOT use Lightning. http://www.macobserver.com/imgs/teaser_images/20120912lightning_connector_usb.jp g

  • Can I use "apple script" to auto input xml file to final cut pro and auto export mp4 file?

    Now, I'v a lot of  final cut pro x 's xml, I want to use ""apple script" or other method to auto input xml and output mp4 in final cut pro x . How can I finish it?

    Where did the XML come from? What did it consist of?

  • Can someone post a pic of a new iPad with no light bleeding

    If you have an iPad with no light bleeding can you post a pic. I don't believe they exist

    I have it but not horribly. I have resigned myself to wait until the mad rush for the iPad2 is over and see how they resolve the issue. Reminds me of the iPhone4 camera problem with white balance. Eventually they solved it. At that point I took mine (iPhone) back (several months later)and they still replaced it without questions. I am suspecting they will do the same with the iPads.

  • Can someone run this for me and tell me what it prints out?

    I am on a computer that does not have BlueJ or anything of the sort and I need to check if this compiles and prints out the correct number. If someone could, please do so and tell me what it prints.
    Thank you
    public static void mystery(int m)
    if (m == 0)
       return 1;
    else
    return 3 * mystery(m - 1);
    }

    Alan.L.Brown wrote:
    What's a "scut-puppy"?Someone who is forced to do low-level dirty work, "scut" work. Scut is a medical term for tasks that medical students and residents don't like doing, such as drawing blood, running something to the lab, starting IV's, lumbar punctures. Usually the low-man on the totem pole who gets assigned to do the scut work is the scut-puppy.

  • Can someone explain why one code works and the other one doesn't?

    Hi,
    I have been doing a little work with XML today and I wrote the following code which did not function properly. In short, it was as if there were elements in the NodeList that disappeared after the initial call to NodeList.getElementsByTagName("span"); The code completely drops through the for loop when I make a call to getTextContent, even though it is not a controlling variable and it does not throw an exception! I'm befuddled. The second portion of code works. For what it is worth, tidy is the HTML cleaner that's been ported to java (JTidy) and parseDOM(InputStream, OutputStream) is supposed to return a Document, which it does! So why I have to call a DocumentBuilderFactory and then get a DocumentBuilder is beyond me. If I don't call Node.getTextContent() the list is processed properly and calls to toString() indicate that the class nodes are in the list! Any help would be appreciated!
    import com.boeing.ict.pdemo.io.NullOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.util.Properties;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    import org.w3c.tidy.Tidy;
    public class HTMLDocumentProcessor {
        // class fields
        private Properties tidyProperties   = null;
        private final String tidyConfigFile =
                "com/boeing/ict/pdemo/resources/TidyConfiguration.properties";
         * Creates a new instance of HTMLDocumentProcessor
        public HTMLDocumentProcessor() {
            initComponents();
        private void initComponents() {
            try {
                tidyProperties = new Properties();
                tidyProperties.load(ClassLoader.getSystemResourceAsStream(tidyConfigFile));
            } catch (IOException ignore) {
        public Document cleanPage(InputStream docStream) throws IOException {
            Document doc = null;
            NullOutputStream nos = new NullOutputStream(); // A NullOutputStream is
                                                           // is used to keep all the
                                                           // error output from printing
            // check to see if we were successful at loading properties
            if (tidyProperties.isEmpty()) {
                System.err.println("Unable to load configuration file for Tidy");
                System.err.println("Proceeding with default configuration");
            Tidy tidy = new Tidy();
            // set some local, non-destructive settings
            tidy.setQuiet(true);
            tidy.setErrout(new PrintWriter(nos));
            tidy.setConfigurationFromProps(tidyProperties);
            doc = tidy.parseDOM(docStream, nos);
            // assuming everything has gone ok, we return the root element
            return doc;
        public static void main(String[] args) {
            try {
                String fileName = "C:/tmp/metars-search.htm";
                File htmlFile = new File(fileName);
                if (!htmlFile.exists()) {
                    System.err.println("File : " + fileName + " does not exist for reading");
                    System.exit(0);
                FileInputStream fis = new FileInputStream(htmlFile);
                HTMLDocumentProcessor processor = new HTMLDocumentProcessor();
                Document doc = processor.cleanPage(fis);
                if (doc == null) {
                   System.out.println("cleanPage(InputStream) returned null Document");
                   System.exit(0);
                NodeList spanTags = doc.getElementsByTagName("span");
                int numSpanTags = spanTags.getLength();
                System.out.println("Number of <span> tags = " + numSpanTags);
                for (int i = 0; i < numSpanTags; i++) { // Loop falls through here!
                    System.out.println("Span tag (" + i + ") = " +
                                        spanTags.item(i).getTextContent());
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                System.exit(0);
    }This segment of code works!
    import com.boeing.ict.pdemo.io.NullOutputStream;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.util.Properties;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    import org.w3c.tidy.Tidy;
    import org.xml.sax.SAXException;
    * Class designed to remove specific notam entries from the
    * HTML document returned in a request. The document will contain
    * either formatted (HTML with CSS) or raw (HTML, pre tags). The
    * Formatted HTML will extract the paragraph body information from the
    * document in it's formatted state. The raw format will extract data
    * as simple lines of text.
    * @author John M. Resler (Capt. USAF, Ret.)<br/>
    * Class : NotamExtractor<br/>
    * Compiler : Sun J2SE version 1.5.0_06<br/>
    * Date : June 15, 2006<br/>
    * Time : 11:05 AM<br/>
    public class HTMLDocumentProcessor {
        // class fields
        private Properties tidyProperties   = null;
        private final String tidyConfigFile =
                "com/boeing/ict/pdemo/resources/TidyConfiguration.properties";
         * Creates a new instance of HTMLDocumentProcessor
        public HTMLDocumentProcessor() {
            initComponents();
        private void initComponents() {
            try {
                tidyProperties = new Properties();
                tidyProperties.load(ClassLoader.getSystemResourceAsStream(tidyConfigFile));
            } catch (IOException ignore) {
        public Document cleanPage(InputStream docStream) throws IOException {
            Document doc = null;
            NullOutputStream nos = new NullOutputStream(); // A NullOutputStream is
                                                           // is used to keep all the
                                                           // error output from printing
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            // check to see if we were successful at loading properties
            if (tidyProperties.isEmpty()) {
                System.err.println("Unable to load configuration file for Tidy");
                System.err.println("Proceeding with default configuration");
            Tidy tidy = new Tidy();
            // set some local, non-destructive settings
            tidy.setQuiet(true);
            tidy.setErrout(new PrintWriter(nos));
            tidy.setConfigurationFromProps(tidyProperties);
            doc = tidy.parseDOM(docStream, bos);
            DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = null;
            try {
                docBuilder = docFactory.newDocumentBuilder();
            } catch (ParserConfigurationException ex) {
                ex.printStackTrace();
            try {
                doc = docBuilder.parse(new ByteArrayInputStream(bos.toByteArray()));
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (SAXException ex) {
                ex.printStackTrace();
            // assuming everything has gone ok, we return the root element
            return doc;
        public static void main(String[] args) {
            try {
                String fileName = "C:/tmp/metars-search.htm";
                File htmlFile = new File(fileName);
                if (!htmlFile.exists()) {
                    System.err.println("File : " + fileName + " does not exist for reading");
                    System.exit(0);
                FileInputStream fis = new FileInputStream(htmlFile);
                HTMLDocumentProcessor processor = new HTMLDocumentProcessor();
                Document doc = processor.cleanPage(fis);
                if (doc == null) {
                   System.out.println("cleanPage(InputStream) returned null Document");
                   System.exit(0);
                NodeList spanTags = doc.getElementsByTagName("span");
                int numSpanTags = spanTags.getLength();
                for (int i = 0; i < numSpanTags; i++ ) {
                    System.out.println(spanTags.item(i).getTextContent().trim());
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                System.exit(0);
    }

    Thank you Dr but the following is true:
    I placed this code in the for loop before I posted the question :
    for (int i = 0; i < numSpanTags; i++) { // Loop falls through here!
          System.out.println("Span tag (" + i + ") = " + spanTags.item(i));
    }And I receive 29 (The correct number) of non-null references to objects (Node objects) in the NodeList.
    When I replace the exact same for loop with this code :
    for (int i = 0; i < numSpanTags; i++) { // Loop falls through here!
          System.out.println("Span tag (" + i + ") = " + spanTags.item(i).getTextContent());
    }Nothing prints. This discussion has never been about "clever means to suppress exceptions" it has been precisely about why a loop that has the
    exact same references, exact same indices prints one time and doesn't print the other and does not throw an exception. If you can answer
    that question then I am interested. I am not interested in pursuing avenues that are incorrect, not understood and most importantly shot from the hip without much thought.

  • Can someone please help me code scrollbars to scroll a movieclip?

    Hi guys,
    Thanks for the interest in my post...
    I've created a scrollbar with up and down buttons for a site
    in Flash 8 but the up button was behaving very oddly even though
    there were no syntax errors.
    Because of this I have decided to start again as nobody could
    find what was going wrong.
    I've created an fla (www.spindriftmedia.com/scroll.fla) with
    all all the elements that will be used but would really appreciate
    it if you wouldn't mind taking a few moments to add the code to the
    buttons and dragger to make it work if that's alright please. I've
    looked all over for tutorials but just can't find anything relevant
    other than the one I used originally.
    Thank you very much and I hope to hear from you.
    Take care,
    Mark

    Generally, people will not download files, so your chances of getting help improve if you include everything in your posting.  In this case you should include the relevant code with which you are having trouble.  Since you say it goes one way or another, I assume that involves coding it different ways, so it might be helpful to show and explain both.

Maybe you are looking for

  • Can i use a hdmi to mini display port cable to use my iMac as external monitor for a windows laptop?

    Does anyone know if a hdmi to mini display port cable can be used to link a  windows laptop with an 27 inch iMac to use the iMac as an external monitor. Or are there other options to connect my DELL latitude 6430?

  • Imovie 5.0.4 crashes upon connection to deck

    I just upgraded from panther to Tiger. Using ilife 5, I can no longer connect a dv deck or camera to the firewire port without the program crashing within seconds. I can connect a firewire drive no problem but not a deck or camera. Os 10.4.4 ibook 1.

  • Lookout 5.1 & 6.1 locking up

    During last two weeks, lookout Ver 5.1 which has been running without problems for a couple of years started locking up with out warning usually around midnight or shortly after. Attempted all recommended fixes that I could find from the website and

  • Palm Centro locks everytime I close a program by pressing End? Please Help

    I recently bought a palm centro for my girlfriend and she is having a huge problem everytime she closes a app or ends a call by pressing the red/end key it locks the phone is there any way to get rid of this feature? I apologize if I didnt post in th

  • Passwords not saving

    I have recently upgraded to firefox 4.0.1 and firefox no longer remembers any of my logins. This includes html logins (via a form). And also server level logins (the ones that pop up before the page even loads). This is certainly not an issue with th