Trying to decide between XPath and one-level-at-a-time found an ideal3rd. way

Discussion in 'XML' started by Cambridge Ray, Jul 27, 2011.

  1. (newbie alert)

    I found two (DOM) tutorial-type programs to retrieve values and I am
    trying to decide which one I will build upon.

    (For this explanation, I will use the filesystem analogy.)

    One of them is simpler, being based on XPath:

    cat /some/dir/inside/another/item.txt

    The other program goes like this:

    cd some
    cd dir
    cd inside
    cd another
    cat item.txt

    (the above are actually nested loops)

    I now realize that the two approaches would be even more useful, if
    combined into a hybrid approach:

    cd /some/dir/inside/another
    dir
    cat item.txt
    cat other.txt

    Is there such express way to jump directly to the desired depth where
    your target item resides?

    TIA,

    -RFH
     
    Cambridge Ray, Jul 27, 2011
    #1
    1. Advertising

  2. Re: Trying to decide between XPath and one-level-at-a-time found anideal 3rd. way

    On Jul 27, 10:23 am, Cambridge Ray <> wrote:
    > (newbie alert)
    >
    > I found two (DOM) tutorial-type programs to retrieve values and I am
    > trying to decide which one I will build upon.
    >
    > (For this explanation, I will use the filesystem analogy.)
    >
    > One of them is simpler, being based on XPath:
    >
    > cat /some/dir/inside/another/item.txt
    >
    > The other program goes like this:
    >
    > cd some
    > cd dir
    > cd inside
    > cd another
    > cat item.txt
    >
    > (the above are actually nested loops)
    >
    > I now realize that the two approaches would be even more useful, if
    > combined into a hybrid approach:
    >
    > cd /some/dir/inside/another
    > dir
    > cat item.txt
    > cat other.txt
    >
    > Is there such express way to jump directly to the desired depth where
    > your target item resides?
    >
    > TIA,
    >
    > -RFH


    As long as I using a filesystem analogy, what I am looking for would
    be like this Unix command:

    mkdir -p some/dir/inside/another

    Which creates all unexistent directories.

    -RFH
     
    Cambridge Ray, Jul 27, 2011
    #2
    1. Advertising

  3. Re: Trying to decide between XPath and one-level-at-a-time found anideal 3rd. way

    On Jul 27, 10:23 am, Cambridge Ray <> wrote:
    > (newbie alert)
    >
    > I found two (DOM) tutorial-type programs to retrieve values and I am
    > trying to decide which one I will build upon.
    >
    > (For this explanation, I will use the filesystem analogy.)
    >
    > One of them is simpler, being based on XPath:
    >
    > cat /some/dir/inside/another/item.txt
    >
    > The other program goes like this:
    >
    > cd some
    > cd dir
    > cd inside
    > cd another
    > cat item.txt
    >
    > (the above are actually nested loops)
    >
    > I now realize that the two approaches would be even more useful, if
    > combined into a hybrid approach:
    >
    > cd /some/dir/inside/another
    > dir
    > cat item.txt
    > cat other.txt
    >
    > Is there such express way to jump directly to the desired depth where
    > your target item resides?
    >
    > TIA,
    >
    > -RFH


    I forgot to mention that I use Xerces-C++, which is very powerful, but
    has a steep learning curve.

    -RFH
     
    Cambridge Ray, Jul 27, 2011
    #3
  4. Re: Trying to decide between XPath and one-level-at-a-time foundan ideal 3rd. way

    On 7/27/2011 11:28 AM, Cambridge Ray wrote:
    > As long as I using a filesystem analogy, what I am looking for would
    > be like this Unix command:
    >
    > mkdir -p some/dir/inside/another
    >
    > Which creates all unexistent directories.


    That's an underspecified behavior, since you haven't said WHERE it
    should create them if other children are already present. (Remember, the
    order may be meaningful in some documents, and/or may be constrained by
    the DTD or Schema.)

    I think the application code needs to be a bit more thoughtful about this.


    --
    Joe Kesselman,
    http://www.love-song-productions.com/people/keshlam/index.html

    {} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
    /\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
     
    Joe Kesselman, Jul 28, 2011
    #4
    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. Nicolas STAMPF
    Replies:
    0
    Views:
    421
    Nicolas STAMPF
    May 4, 2004
  2. abc
    Replies:
    1
    Views:
    435
    Aytaç ÖZAY
    Apr 7, 2006
  3. pabbu
    Replies:
    8
    Views:
    773
    Marc Boyer
    Nov 7, 2005
  4. Google Poster

    Trying to decide between PHP and Python

    Google Poster, Jan 4, 2011, in forum: Python
    Replies:
    37
    Views:
    847
    Benjamin J. Racine
    Feb 10, 2011
  5. Crep Cat
    Replies:
    5
    Views:
    166
Loading...

Share This Page