Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-13-2007, 03:36 PM
Member
 
Join Date: Jul 2007
Posts: 44
Rep Power: 0
simon is on a distinguished road
Default Searching XML file using DOM
I have an XML file that I read using DOM. The file is that:
Code:
<database>
<object id="0001">
more elements here
</object>
<object id="0002">
more elements here
</object>
and so on....
</database>
I want to be able to retrieve the element where id=xxxx. And I should also be able to access the elements that are in the object element I found.
can I do that?


thank you
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-15-2007, 12:55 AM
Member
 
Join Date: Jul 2007
Posts: 39
Rep Power: 0
christina is on a distinguished road
Default
I think it is better to use SAX than DOM to search the xml file if the xml is going to be to big and it will work fast.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-31-2007, 12:55 AM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
Default
You can also use XPath to get what you want.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-01-2007, 05:38 PM
Member
 
Join Date: Jul 2007
Posts: 44
Rep Power: 0
simon is on a distinguished road
Default
Thanks guys, I finally used XPath.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-28-2008, 09:06 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,446
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Actually use XPath is much easier. Quite similar question discuss here few days back, how to update an XML file. Same procedure have to follow.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 03-30-2009, 02:27 AM
Member
 
Join Date: Mar 2009
Posts: 10
Rep Power: 0
vogash is on a distinguished road
Default
i agree, we also XPath.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
Searching an arraylist adelgado0723 New To Java 1 04-15-2008 02:09 PM
Sorting, Searching, and Inserting into a sorted array Java Tip java.lang 0 04-14-2008 09:39 PM
recursively searching through arraylists newtojava7 New To Java 1 03-17-2008 03:36 AM
searching within a JList newtojava7 New To Java 1 03-10-2008 01:12 AM
searching nalinda New To Java 3 12-06-2007 03:56 AM


All times are GMT +2. The time now is 12:18 AM.



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