D
Domenick
I would like to parse an HTML file and retrieve certain pieces of
information from the page. I have already read the file into a string,
and I have been using a very inefficient way to get the data I am
looking for. From what I remember in school, regular expressions
should do the trick, but I am not very familiar with them in Java and I
am not very familiar with Patterns in Java either. Given the string
below:
<html>
<head>
<title>The Title</title>
</head>
<body>
<span id="user1Control" class="user">Player 1 Name</span>
<span id="user2Control" class="user">Player 2 Name</span>
..
..
..
<span id="usernControl" class="user">Player n Name</span>
</body>
</html>
What would be the best way to get an array of Strings containing
Player 1 Name
Player 2 Name
Player 3 Name?
Also, in the HTML file I would like to parse, the actual "Player 1
Name" would be John Smith, and "Player 2 Name" would be Bill Jones,
etc....
Finally, the above HTML Example is a trimmed down version of the HTML
file that I will be parsing, and I would like to avoid calling "split"
on the string to try to retrieve the information that I am looking for.
I would like to learn how to do this using regular expressions and
patterns.
Any help or direction would be apprecited. Thanks in advance.
- Domenick
information from the page. I have already read the file into a string,
and I have been using a very inefficient way to get the data I am
looking for. From what I remember in school, regular expressions
should do the trick, but I am not very familiar with them in Java and I
am not very familiar with Patterns in Java either. Given the string
below:
<html>
<head>
<title>The Title</title>
</head>
<body>
<span id="user1Control" class="user">Player 1 Name</span>
<span id="user2Control" class="user">Player 2 Name</span>
..
..
..
<span id="usernControl" class="user">Player n Name</span>
</body>
</html>
What would be the best way to get an array of Strings containing
Player 1 Name
Player 2 Name
Player 3 Name?
Also, in the HTML file I would like to parse, the actual "Player 1
Name" would be John Smith, and "Player 2 Name" would be Bill Jones,
etc....
Finally, the above HTML Example is a trimmed down version of the HTML
file that I will be parsing, and I would like to avoid calling "split"
on the string to try to retrieve the information that I am looking for.
I would like to learn how to do this using regular expressions and
patterns.
Any help or direction would be apprecited. Thanks in advance.
- Domenick