Fast & Simple Data Extraction From XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laura p

    #1

    Fast & Simple Data Extraction From XML

    Hi,

    I have a substantial xml file, which represents a large chunk of system
    data. In one part of my application I want to retrieve three or four
    elements from this xml.

    At this point, I do not have the XML stored in memory as a DOM. It
    seems like a lot of processing to convert it into a DOM just to
    retrieve a few elements, likewise, I have no idea where in the file the
    elements are, so it take some time to parse it using SAX.

    Does anyone have any suggestions on how I could simply and quickly
    extract the elements I need without having to process the whole xml
    file?

    Thank you,
    Laura

  • Ted Dunning

    #2
    Re: Fast & Simple Data Extraction From XML


    If you are using SAX to parse the file, you can use the event based
    model to find the elements you are interested in and then abort
    processing the file.

    Even cooler, however, would be to essentially store an index of file
    offsets to various sub-elements in a threaded persistent data
    structure. That would let you extract bits (after paying the indexing
    cost) at very high speed.

    If you were to say more about your application such as whether you have
    to search the file multiple times and whether it changes, then others
    would be able to comment more specifically.

    I hope that this helps anyway.

    Comment

    Working...