3

I have xml Like:

<OuterTag>

    <InnerTag>

        <content:encoded><![CDATA[Huawei have entered the smartphone race by unveiling their own quad core devices and the Chinese...<br/>
        <br/>
        </div>]]>

        </content:encoded>

    </InnerTag>

</OuterTag>

I can Get all the value from simple tags, but i can not get from <content:encoded>, How can I solve it?

Alex K
  • 22,315
  • 19
  • 108
  • 236
  • u want to parse content:encoded tag & get data from that tag? – Sumant Feb 28 '12 at 07:38
  • start element: if (localName.equals("content:encoded")) { contentOn = true; channelparse=false; } character: if (contentOn==true && channelparse==false) { contentValue = new String(ch, start, length); contentOn = false; } end element: if (localName.equalsIgnoreCase("content:encoded")&& channelparse==false) { data.setcontent(contentValue); } get: public ArrayList gotcontent() { // TODO Auto-generated method stub return data.getcontent(); } – Nirupoma Saha Chaiti Feb 28 '12 at 07:45

2 Answers2

2

I had the same problem lately, instead of content:encoded use encoded in your code.

if (localName.equals("encoded")) // not content:encoded
Mike
  • 819
  • 1
  • 8
  • 14
0

check this it might solve u r problem

StringBuilder stringBuilder;

start element: 
       if (localName.equals("content:encoded")) 
       {
        contentOn = true; channelparse=false; 
        stringBuilder = new StringBuilder();
       }
       character: 
       if (contentOn==true && channelparse==false) 
       { 
         contentValue =""; 
         contentValue = new String(ch, start, length); 
         stringBuilder.append(contentValue);
         contentOn = false; 
       } 
      end element: 
      if (localName.equalsIgnoreCase("content:encoded")&& channelparse==false)
       { 
        data.setcontent(stringBuilder.toString()); 
       }
      get: public ArrayList<String> gotcontent() 
     { 
      return data.getcontent(); 
     } 
Sumant
  • 2,775
  • 2
  • 22
  • 30