0

JAVA SAX パーサーでこのファイルを解析する際に問題が発生しました。

http://feeds.escapeartists.net/PodCastle_Main

ほとんどの場合、Exception: content is not allowed in prolog が発生します

Notepad++ でファイルを表示しました。プロローグは問題ありません。少なくともそう思います。

他の多くのポッドキャスト フィードが機能します。http://feeds.feedburner.com/newz-of-the-world

興味深いことに、ポッドキャッスル フィードは約 10% の成功率で動作します。

助言がありますか ?

br ユルゲン

編集: 興味深いことに、ファイルを手動でダウンロードし、自分の Web スペースにアップロードしました。- そこからはすべて順調です...奇妙です

EDIT2: コード

        URL url = new URL(this.urlString);
        _setProxy(); // Set the proxy if needed 
        urlInputStream = url.openConnection().getInputStream();

        spf = SAXParserFactory.newInstance();
        sp = spf.newSAXParser();

        if ( urlInputStream == null) {
            System.out.println("blub blub");
        }
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));

        System.out.println ("<<<<"+this.urlString+">>>> :" +  in.readLine() );
        System.out.println ("<<<<"+this.urlString+">>>> :" +  in.readLine() );
        in.close();


        InputStream is = url.openStream();

        try {

        sp.parse(url.toURI().toString(), this);

        } catch (SAXParseException e) {
            System.err.println(e.getMessage());
        }

出力:

<<<< ttp://feeds.escapeartists.net/PodCastle_Main>>>> : (印刷できない文字) <<<< ttp://feeds.escapeartists.net/PodCastle_Main>>>> : (印刷できない文字)

com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 1 バイト UTF-8 シーケンスのバイト 1 が無効です。...

saxパーサーの同様の例外...

問題はサックスではなく、データ伝送です。約半分の時間で機能します。他のすべての testet .xml ファイルは機能します。

誰かこの効果を知っていますか?

4

2 に答える 2

0

これで、この回避策を実装しました。投稿されたウェブサイトのウェブサーバーに問題があると思います

       int TRIES = 10;
        for (int tries = 0; tries < TRIES; tries++) {
            InputStream is = url.openStream();
            try {

                sp.parse(is, this);
                //here succesfull
                tries = TRIES; //break loop

            } catch (SAXParseException e) {
                System.err.println(e.getMessage());
            } catch (MalformedByteSequenceException ex) {
                System.out.println("Connection to " + url.toString() + " failed "+ (tries+1) +" times , trying again... (maximum tries = "+ TRIES +")");
                 Thread.sleep(250);
            }
      }

2〜3回試行した後、ストリームは機能します

于 2012-08-21T06:49:00.210 に答える
0

おそらく、ドキュメントの先頭がきれいではありません。余分な文字が誤って 1 つか 2 つ入り込んでいる可能性があります。オブジェクトが対象としている行と列を SAXException から抽出できるはずです。

于 2013-09-30T13:23:24.840 に答える