Reading Data From An XML File

Discussion in 'Java' started by mich, Jul 28, 2007.

  1. mich

    mich Guest

    Since this obviously changes over time what is currently the most effective
    way to read parts of am XML file?


    Thanks!!
    mich, Jul 28, 2007
    #1
    1. Advertising

  2. mich schrieb:
    > Since this obviously changes over time what is currently the most effective
    > way to read parts of am XML file?
    >
    >
    > Thanks!!
    >
    >

    The SAX parser is up to date and one of the current best parsing
    solutions when XML streams are analyzed with saving heap.

    http://sax.sourceforge.net/

    regards

    Torsten Jenkner
    Torsten Jenkner, Jul 28, 2007
    #2
    1. Advertising

  3. mich

    Daniel Pitts Guest

    Re: Reading Data From An XML File

    On Jul 27, 4:27 pm, "mich" <> wrote:
    > Since this obviously changes over time what is currently the most effective
    > way to read parts of am XML file?
    >
    > Thanks!!



    It depends on your need.
    If you are fine with reading the whole XML file into memory, you can
    use DocumentBuilder, and pass it the URL to your XML file, you'll get
    back a Document object which implements the DOM.
    Daniel Pitts, Jul 28, 2007
    #3
  4. mich

    Guest

    Re: Reading Data From An XML File

    On Jul 27, 7:27 pm, "mich" <> wrote:
    > Since this obviously changes over time what is currently the most effective
    > way to read parts of am XML file?
    >
    > Thanks!!


    It depends what you're doing with the XML. If you need simple, quick
    processing go with SAX. If you want to build a tree structure of the
    XML, check out JDOM.
    , Jul 28, 2007
    #4
  5. mich

    mich Guest

    Re: Reading Data From An XML File

    <> wrote in message
    news:...
    > On Jul 27, 7:27 pm, "mich" <> wrote:
    >> Since this obviously changes over time what is currently the most
    >> effective
    >> way to read parts of am XML file?
    >>
    >> Thanks!!

    >
    > It depends what you're doing with the XML. If you need simple, quick
    > processing go with SAX. If you want to build a tree structure of the
    > XML, check out JDOM.



    Thanks both, and it looks like I'll be going with SAX, since I'm only
    reading the data. While the data will occasionally change I will just do it
    manually.
    mich, Jul 28, 2007
    #5
  6. mich

    JTL.zheng Guest

    Re: Reading Data From An XML File

    On Jul 28, 7:27 am, "mich" <> wrote:
    > Since this obviously changes over time what is currently the most effective
    > way to read parts of am XML file?
    >
    > Thanks!!


    There three choices: SAX, DOM, JDOM

    SAX: use less memory, faster, but not easy to use
    DOM: use more menory as it reads all the XML tree when initialize,
    easy to use
    JDOM: use less menory and faster than DOM as it only reads which it
    needs, and more easy to use
    JTL.zheng, Jul 28, 2007
    #6
  7. mich

    Roedy Green Guest

    >Since this obviously changes over time what is currently the most effective
    >way to read parts of am XML file?

    See http://mindprod.com/jgloss/xml.html
    for your options. You DON'T have to write your own parser. Java has
    them built in now.
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Jul 28, 2007
    #7
  8. mich

    mich Guest

    Re: Reading Data From An XML File

    "JTL.zheng" <> wrote in message
    news:...
    > On Jul 28, 7:27 am, "mich" <> wrote:
    >> Since this obviously changes over time what is currently the most
    >> effective
    >> way to read parts of am XML file?
    >>
    >> Thanks!!

    >
    > There three choices: SAX, DOM, JDOM
    >
    > SAX: use less memory, faster, but not easy to use
    > DOM: use more menory as it reads all the XML tree when initialize,
    > easy to use
    > JDOM: use less menory and faster than DOM as it only reads which it
    > needs, and more easy to use



    Since I'm just going to be reading the XML file to get some data - no
    updating - it should be better if create a singleton class to read it. The
    XML file will hold product information, but since the business will not have
    many products an XML file makes sence.

    Another aspect that I'm looking at is simulating an index by giving a
    different node name to each product, example below:

    <catalog>
    <largeWatermelon/>
    <organicWatermelon/>
    </catalog>

    If the catalog gets too big I can also just have different XML files for
    different produc groups, such as one file for vegetables, one for fruits,
    mich, Jul 28, 2007
    #8
  9. mich

    Lew Guest

    Re: Reading Data From An XML File

    JTL.zheng wrote:
    > On Jul 28, 7:27 am, "mich" <> wrote:
    >> Since this obviously changes over time what is currently the most effective
    >> way to read parts of am XML file?
    >>
    >> Thanks!!

    >
    > There three choices: SAX, DOM, JDOM
    >
    > SAX: use less memory, faster, but not easy to use
    > DOM: use more menory as it reads all the XML tree when initialize,
    > easy to use
    > JDOM: use less menory and faster than DOM as it only reads which it
    > needs, and more easy to use


    Four: StAX.

    --
    Lew
    Lew, Jul 28, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWF0dCBIb2xsaW5nd29ydGg=?=

    Reading UTF-8 Data from XML file

    =?Utf-8?B?TWF0dCBIb2xsaW5nd29ydGg=?=, May 26, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    3,917
    Joerg Jooss
    Jun 3, 2005
  2. jkflens
    Replies:
    2
    Views:
    1,469
    jkflens
    May 30, 2006
  3. Replies:
    0
    Views:
    782
  4. Erik Wasser
    Replies:
    5
    Views:
    451
    Peter J. Holzer
    Mar 5, 2006
  5. Replies:
    5
    Views:
    80
    Chris Angelico
    May 14, 2014
Loading...

Share This Page