Results 1 to 6 of 6
Thread: Help with html tags in java
- 02-02-2010, 09:34 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 21
- Rep Power
- 0
- 02-02-2010, 12:42 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Take a look here for a free parsers:
Open Source HTML Parsers in Java
I cannot know which one will fulfill your needs,
but important thing is that parser is smart enough to clean
all non-tag content, so you can easily get what's inside of tags.
good luck
- 02-02-2010, 03:49 PM #3
Member
- Join Date
- Feb 2010
- Posts
- 21
- Rep Power
- 0
for example:
<body>
text text
word1 word2
sentence text word
</body>
if i have text like this between tags the result is: "text text word1 word2 sentence text word" if i use stringtokenizer I get
text
text
word1
word2
sentence
text
word
what i need is that when read that text between tags and I want to get it as it was before. The result I need is:
text text
word1 word2
sentence text word
I tried using parser, but it does not works like i need
Please help
-
- 02-02-2010, 11:45 PM #5
Member
- Join Date
- Feb 2010
- Posts
- 21
- Rep Power
- 0
I found a solution
Here it is, maybe you need it someday:
public void getTextBetweenBodyTags() throws IOException{
ArrayList<String> textBetweenBody = new ArrayList<String>();
int findBody = 0;
File file = new File(inPutfile);
BufferedReader reader = null;
String line;
try{
reader = new BufferedReader(new FileReader(file));
while ((line = reader.readLine()) != null){
if (line.equals("</body>")){
findBody = 0;
}
if (findBody == 1){
textBetweenBody.add(line);
}
if (line.equals("<body>")){
findBody = 1;
}
}
} catch (FileNotFoundException e){
e.printStackTrace();
}
}
- 02-03-2010, 06:13 AM #6
Senior Member
- Join Date
- Oct 2009
- Location
- California,US
- Posts
- 201
- Rep Power
- 4
Similar Threads
-
Need help in validation HTML tags
By nn12 in forum New To JavaReplies: 1Last Post: 09-09-2008, 04:18 AM -
HTML tags anyone?
By tim in forum Suggestions & FeedbackReplies: 2Last Post: 06-29-2008, 04:49 AM -
Html tags within XML- need help
By iamhappy in forum XMLReplies: 2Last Post: 03-27-2008, 04:21 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks