Results 1 to 6 of 6
  1. #1
    simon is offline Member
    Join Date
    Jul 2007
    Posts
    44
    Rep Power
    0

    Default Searching XML file using DOM

    I have an XML file that I read using DOM. The file is that:
    Java 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

  2. #2
    christina is offline Member
    Join Date
    Jul 2007
    Posts
    39
    Rep Power
    0

    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.

  3. #3
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    You can also use XPath to get what you want.

  4. #4
    simon is offline Member
    Join Date
    Jul 2007
    Posts
    44
    Rep Power
    0

    Default

    Thanks guys, I finally used XPath.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    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.

  6. #6
    vogash is offline Member
    Join Date
    Mar 2009
    Posts
    10
    Rep Power
    0

Similar Threads

  1. Searching an arraylist
    By adelgado0723 in forum New To Java
    Replies: 1
    Last Post: 04-15-2008, 01:09 PM
  2. Replies: 0
    Last Post: 04-14-2008, 08:39 PM
  3. recursively searching through arraylists
    By newtojava7 in forum New To Java
    Replies: 1
    Last Post: 03-17-2008, 02:36 AM
  4. searching within a JList
    By newtojava7 in forum New To Java
    Replies: 1
    Last Post: 03-10-2008, 12:12 AM
  5. searching
    By nalinda in forum New To Java
    Replies: 3
    Last Post: 12-06-2007, 02:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •