java-memidp-2.0

How to do Parsing in j2me(java)


i want to extract the

iframe tag "src" value from the below url http://www.teluguone.com/videos/single/comedy/Comedy-Express-464---Back-to-Back---Comedy-Scenes-14727.html

iframe width="640" height="380" src="http://www.youtube.com/embed/XJDw2T1nGJQ"frameborder="0"

allowfullscreen/iframe

How can i achieve it in j2me?htmlparser ,Jericho ,Jsoup parser are not supported in j2me


Solution

  • Assuming you already have the html source stored in a String variable called htmlPage.

    int iFrameIndex = htmlPage.indexOf("iframe");
    int srcIndex = htmlPage.indexOf("src", iFrameIndex);
    int httpIndex = htmlPage.indexOf("http", srcIndex);
    int quotesIndex = htmlPage.indexOf("\"", httpIndex);
    String srcUrl = htmlPage.substring(httpIndex, quotesIndex);