0

i am doing JSON parsing for particular web service with different IDs,Parsing returns some fields like "Description,unitcost,saleprice,summary etc.., In Description field i am getting data in HTML format, But HTML Structure is not unique for each ID, these are the urls i am using

http://demo.s2commerce.net/DesktopModules/S2Commerce/S2Commerce.svc/rest/ProductID/8/Portal/0

http://demo.s2commerce.net/DesktopModules/S2Commerce/S2Commerce.svc/rest/ProductID/5/Portal/0

And data i am getting in "description" field for 3 urls is below

1."Description":"

 <\/p>\u000d\u000a\u000d\u000a

This exclusive edition is another striking symbol of cooperation between Acer and Ferrari -- two progressive companies with proud heritages built on passion, innovation, power and success<\/p>\u000d\u000a<\/div>\u000d\u000a\u000d\u000a

Acer has flawlessly designed the Ferrari 3200, instilling it with exceptional performance, brilliant graphics, and lightning-fast connectivity. This exclusive edition is another striking symbol of cooperation between Acer and Ferrari -- two progressive companies with proud heritages built on passion, innovation, power and success.<\/p>\u000d\u000a<\/div>\u000d\u000a

 <\/p>",

2."Description":"\u000d\u000a

A technically sophisticated point-and-shoot camera offering a number of pioneering technologies such as Dual Image Stabilization, Bright Capture Technology, and TruePic Turbo, as well as a powerful 5x optical zoom.<\/p>\u000d\u000a<\/div>\u000d\u000a\u000d\u000a

Olympus continues to innovate with the launch of the Stylus 750 digital camera, a technically sophisticated point-and-shoot camera offering a number of pioneering technologies such as Dual Image Stabilization, Bright Capture Technology, and TruePic Turbo, as well as a powerful 5x optical zoom that tucks away into a streamlined metal, all-weather body design. The camera is distinguished by a number of premium features, including:<\/p>\u000d\u000a

* An advanced combination of the mechanical CCD-shift Image Stabilization and Digital Image Stabilization work together to ensure the clearest pictures possible in any situation;\u000d\u000a* A 5x optical zoom lens with a newly developed lens element to maintain a small compact size;\u000d\u000a* A 2.5-inch LCD and Bright Capture Technology dramatically improve composition, capture and review of images in low-light situations;\u000d\u000a* Olympus' exclusive TruePic Turbo Image Processing engine is coupled with a 7.1-megapixel image sensor to produce crisp, high-quality p<\/p>\u000d\u000a<\/div>

i want to get only paragraphs between paragraphs tags.

can anyone suggest me to do this?

thanks in advance

Abhi
  • 8,935
  • 7
  • 37
  • 60

2 Answers2

0

You can use regular expressions. Something like this

String description = "test <p> some \n string <\\/p> skip this <p> another <\\/p> not in range";

...

if (!"".equals(description)) {
  Pattern p = Pattern.compile("\\Q<p>\\E[\\w|\\s]*\\Q<\\/p>\\E");
  Matcher m = p.matcher(description);
  while (m.find()) { 
    String ptag = m.group(); 
    Log.d("regex", ptag);
  } 
}

this will find every part of text between <p> and <\/p>. Maybe, you'll need some modiifications. See all supported RegEx instructions in documentation

user711058
  • 675
  • 7
  • 11
0

just see this link. Is it possible to have multiple styles inside a TextView?

you just need to set the string data parsed from json in to this textview.

Community
  • 1
  • 1
Hitendra
  • 3,218
  • 7
  • 45
  • 74