Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2003
    Location
    London
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    simple search of an XML document

    Is there a simple search method, using java, for a XML document.

    The search does not need to be based on element values, but if it is thats fine too.

    thanks

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    What are you searching for? An element? A certain string of text?

    What application is doing the searching?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    New to the CF scene
    Join Date
    Jul 2003
    Location
    London
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Im searching XML files of an unknown format and structure (i dont know the element names beforehand), thus I need to search on the actual data content.

    Im using Java, Xreces and the DOM API for my application which currently parses an XML file.

    Thus the next step is to search the parsed file (held in a DOM structure) it for keywords contained within the data content.

    How best can I do this ?

    Thanks very much

  • #4
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    I assume by content you mean text.

    Your best friend for searching for a particular section of text might be DOM 2 Traversal. Unless there are element tags (not nodes, but tags) in the middle of your text...

    If there are, then DOM 2 Range can get you the text, the whole text and nothing but the text and you can do a simple regular expression check against that.

    Try not to use proprietary extensions like innerText; I seriously doubt anybody but IE supports them.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

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