Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2008, 09:31 PM
Member
 
Join Date: Jul 2008
Posts: 3
jaadu25 is on a distinguished road
Parsing HTML
I am trying to parse the HTML, and for a HTML code like this

<span class="authorName">Paul Abbott </span>
I want to retrieve the value "Paul Abbott"

Right now, I am using a parser, to generate the HTML tree and by using the this code..
************************************************** *******************
Tidy tidy = new Tidy();
tidy.setXHTML(xhtml);
d = tidy.parseDOM(in,out);


NodeList spanNode = d.getElementsByTagName("span");
int length = spanNode.getLength();
for(int i = 0;i<length;i++)
{
org.w3c.dom.Node span = spanNode.item(i);
String tempAltText = span.getAttributes().getNamedItem("class").getNode Value();
if(tempAltText.equals("authorName")){

System.out.println("the item is " + tempAltText);
}
else{

}
}

************************************************** ************

The tempAltText displays "authorName" but not "Paul Abott"
please give me some suggestions...how can i do that...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-18-2008, 12:20 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Norm is on a distinguished road
Don't know about parsing HTML, but your if test give you what you want.
Its like asking if x == 1 and then being suprised that x is equal to 1. Perhaps you need to get some other item.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-18-2008, 12:27 AM
Member
 
Join Date: Jul 2008
Posts: 3
jaadu25 is on a distinguished road
The thing is I want to dispaly "paul Abott" not "authorName".....how can i do that...
Is it clear now...or if you need more explanation...let me know..
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-18-2008, 09:53 PM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 533
fishtoprecords is on a distinguished road
On forums, its generally a good idea to post the solution, so others with the same problem can benefit from the effort you put into finding a solution.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-18-2008, 10:23 PM
Member
 
Join Date: Jul 2008
Posts: 3
jaadu25 is on a distinguished road
I am still looking for the solution..I haven't solved it yet...
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-19-2008, 06:43 PM
Member
 
Join Date: Jul 2008
Posts: 28
Jeremy is on a distinguished road
Are you looking at the API? There are a handful of "get" methods and I'm pretty sure at least one of them works!

Node (Java Platform SE 6)
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-20-2008, 08:51 PM
Member
 
Join Date: Jul 2008
Posts: 32
Engineeringserver.com is on a distinguished road
I've seen a similiar question on the sun java forums and i've answered it but because he went postal i've removed my code and let him sort it out on his own..
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

<--
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Java developer
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
xml parsing gaurav65176 XML 5 11-12-2008 01:07 PM
Parsing URL Java Tip Java Tips 0 12-26-2007 12:16 PM
jeditorpane help parsing html asifsolkar Advanced Java 4 12-14-2007 07:23 AM
Parsing XML documents using DOM JavaForums Java Blogs 0 11-19-2007 06:30 PM
html web page parsing/scraping orchid Advanced Java 1 05-02-2007 05:35 AM


All times are GMT +3. The time now is 08:50 AM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org