Search code examples
jqueryhtmljava-melwuit

html text Extraction between multiple div tags in j2me


I have a html web page url http://teluguone.com/recipes/content/Andhra-Spicy-Mutton-Curry-Recipe-6-221.html

I need to extract Description text from the above url.

My Requirement is, I need to get the text with html tags between multiple DIV tags,

Example:

<div class="relatedarticals_info_bold"><h1>Recipe Name</h1></div> : Andhra Spicy Mutton Curry Recipe</div> 
</div> <div id="relatedarticals_info2"> <div class="relatedarticals_info"> <div class="relatedarticals_info_bold">
<h1>Author</h1></div> : Teluguone</div> </div> <div id="relatedarticals_info2"> <div class="relatedarticals_info">
 <div class="relatedarticals_info_bold"><h1>Preparation Time</h1></div> : 30 Mins</div> </div>etc.....? 

I need to get the output like this:

Recipe Name: Andhra Spicy Mutton Curry Recipe Author: Teluguone 
Preparation Time: 30 Mins etc... 

Solution

  • If the HTML is available as string you can use jQuery's $.parseXML which converts into an XMLDocument if successfully parsed(well-formed HTML).

    This object can then be traversed and manipulated using .find(), .parent() and other such traversal methods.

    Note: That is of course, assuming you're open to doing this on the client-side.