Web Analytics Made Easy -
StatCounter simple search of an XML document - CodingForum

Announcement

Collapse
No announcement yet.

simple search of an XML document

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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, ES-Membrane project (Github Pages site)
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

    Comment


    • #3
      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

      Comment


      • #4
        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, ES-Membrane project (Github Pages site)
        author, Verbosio prototype XML Editor
        author, JavaScript Developer's Dictionary
        https://alexvincent.us/blog

        Comment

        Working...
        X