2011-01-10 1 views
0

私はいくつかのタグを含むこのrssフィードを解析しています。私は説明タグノードを除くすべての値(子要素)を取得することができます。私はこのために使っていたコードは、私が<description>タグの値をキャプチャしようとしたが、そのくぼみがうまく、私はすべての通常のを使用してみましたアンドロイドドムパーサーの問題

StringBuffer descriptionAccumulator = new StringBuffer(); 

else if (property.getNodeName().equals("description")){ 
        try{ 
         String desc = (property.getFirstChild().getNodeValue()); 
         if(property.getNodeName().equals("p")){ 
          descriptionAccumulator.append(property.getFirstChild().getNodeValue()); 
         } 
        } 
        catch(Exception e){ 
         Log.i(tag, "No desc"); 
        } 
else if (property.getNodeName().equals("ens1:org")){ 
       try{ 

         event.setOrganization(property.getFirstChild().getNodeValue()); 
         Log.i(tag,"org"+(property.getFirstChild().getNodeValue())); 
        } 
        catch(Exception e){ 

        } 
else if (property.getNodeName().equals("area")||property.getNodeName().equals("fflag") || property.getNodeName().equals("tflag") || property.getNodeName().equals("guid")){ 
        try{ 
         //event.setOrganization(property.getFirstChild().getNodeValue()); 
         Log.i(tag,"org"+(property.getFirstChild().getNodeValue())); 
        } 
        catch(Exception e){ 

        } 
else if(property.getNodeName().equals("p") || property.getNodeName().equals("em") || property.getNodeName().equals("br") || property.getNodeName().startsWith("em") || property.getNodeName().startsWith("span") || property.getNodeName().startsWith("a") || property.getNodeName().startsWith("div") || property.getNodeName().equals("div") || property.getNodeName().startsWith("p")){ 
        descriptionAccumulator.append(property.getFirstChild().getNodeValue()); 
        descriptionAccumulator.append("."); 
        System.out.println("description added:"+descriptionAccumulator); 
        Log.i("Description",descriptionAccumulator+property.getFirstChild().getNodeValue()); 


       } 

ある

<fflag>0</fflag> 
<tflag>0</tflag> 
<ens1:org>C Opera Production</ens1:org> 
− 
<description> 
<p>Opera to be announced</p> 

<p>$15 adults/$12 seniors/$10 for college students<span style="white-space: pre;"> </span></p> 
</description> 

RSSフィードの下に見つけてください使用されているがまだ途絶えていないhtmlフォーマットタグ。他のパーサーを使用することはオプションではありません。何かの体がこれで私を助けてくれますか?ありがとう

答えて

1

rss xmlでsmthが間違っていると思います。たとえば、返されるxmlがStackOverflow rss feedであるかどうかを確認します。特に、<summary type="html">ノードの内容がどのように見えるかに注意してください。内側に子xmlノードはなく、純粋なxmlエスケープテキストのみです。したがって、あなたのケースでは受け入れられれば、結果を修正するよりも、適切なrss xml生成に努力してください。

0

これはxmlとして解析されているため、descriptionタグには文字列値はなく、複数の子があります。あなたはdescriptionノードを取得して、それをかなり印刷してみるかもしれません。 XMLへの印刷については、LSSerializerを参照してください。

関連する問題