• xpath deeper level but considering siblings

    From frank67x@gmail.com@21:1/5 to All on Tue Feb 16 02:23:19 2016
    Presume following xml:

    <root>
    <main>
    <info name='info_1'>value_1a</info>
    <info name='info_2'>value_2a</info>
    <info name='info_3'>value_3a</info>
    <info name='info_4'>value_4a</info>
    <data>
    <data1>hello</data1>
    <data2>world</data2>
    </data>
    </main>
    <main>
    <info name='info_1'>value_1b</info>
    <info name='info_2'>value_2b</info>
    <info name='info_3'>value_3b</info>
    <info name='info_4'>value_4b</info>
    <data>
    <data1>bye</data1>
    <data2>again</data2>
    </data>
    </main>
    </root>

    What's the xpath to retrieve the value of
    /root/main/data/data1
    of the 1st section, where sibling
    /root/main/info[@name='info1'] has value 'value_1a'?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Tobin@21:1/5 to frank67x@gmail.com on Tue Feb 16 16:21:53 2016
    In article <7e34c25e-3db7-4eaa-a4a1-94779ff87b2a@googlegroups.com>,
    <frank67x@gmail.com> wrote:
    What's the xpath to retrieve the value of
    /root/main/data/data1
    of the 1st section, where sibling
    /root/main/info[@name='info1'] has value 'value_1a'?

    You want the data/data1 of the root/main whose info[@name="info_1"]
    is equal to "value_1a":

    /root/main[info[@name="info_1"]="value_1a"]/data/data1

    -- Richard

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From frank67x@gmail.com@21:1/5 to All on Tue Feb 16 09:16:30 2016
    Am Dienstag, 16. Februar 2016 17:25:04 UTC+1 schrieb Richard Tobin:
    In article <7e34c25e-3db7-4eaa-a4a1-94779ff87b2a@googlegroups.com>,
    <frank67x@gmail.com> wrote:
    What's the xpath to retrieve the value of
    /root/main/data/data1
    of the 1st section, where sibling
    /root/main/info[@name='info1'] has value 'value_1a'?

    You want the data/data1 of the root/main whose info[@name="info_1"]
    is equal to "value_1a":

    /root/main[info[@name="info_1"]="value_1a"]/data/data1

    -- Richard

    - thanks a lot.

    Two next questions:

    1) Is it really "info_1" to use? or does it have to be 'info_1'?
    (double quote or single quote)

    2) Is it also supported to use a combination of criterions?
    Something like e.g.:

    /root/main[info[@name="info_1"]="value_1a"]&&[@name="info_2"]="value_2a"]/data/data1

    Are logical operators supported? (&& above)

    regards,
    Frank

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Tobin@21:1/5 to frank67x@gmail.com on Wed Feb 17 01:01:48 2016
    In article <54d935fd-e3d8-4efd-bd6b-c0e99212407d@googlegroups.com>,
    <frank67x@gmail.com> wrote:

    Two next questions:

    1) Is it really "info_1" to use? or does it have to be 'info_1'?
    (double quote or single quote)

    You can use either kind of quote.

    2) Is it also supported to use a combination of criterions?
    Something like e.g.:

    /root/main[info[@name="info_1"]="value_1a"]&&[@name="info_2"]="value_2a"]/data/data1

    Are logical operators supported? (&& above)

    That would be

    /root/main[info[@name="info_1"]="value_1a" and info[@name="info_2"]="value_2a"]/data/data1

    -- Richard

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From frank67x@gmail.com@21:1/5 to All on Wed Feb 17 00:07:48 2016
    Am Mittwoch, 17. Februar 2016 02:05:04 UTC+1 schrieb Richard Tobin:
    In article <54d935fd-e3d8-4efd-bd6b-c0e99212407d@googlegroups.com>,
    <frank67x@gmail.com> wrote:

    Two next questions:

    1) Is it really "info_1" to use? or does it have to be 'info_1'?
    (double quote or single quote)

    You can use either kind of quote.

    2) Is it also supported to use a combination of criterions?
    Something like e.g.:

    /root/main[info[@name="info_1"]="value_1a"]&&[@name="info_2"]="value_2a"]/data/data1

    Are logical operators supported? (&& above)

    That would be

    /root/main[info[@name="info_1"]="value_1a" and info[@name="info_2"]="value_2a"]/data/data1

    -- Richard

    Hi Richard,
    that's what i was looking for.
    - thanks a lot!
    best regards,
    Frank

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flynn@21:1/5 to Richard Tobin on Sun Feb 21 15:41:35 2016
    On 17/02/16 01:01, Richard Tobin wrote:
    In article <54d935fd-e3d8-4efd-bd6b-c0e99212407d@googlegroups.com>,
    <frank67x@gmail.com> wrote:

    Two next questions:

    1) Is it really "info_1" to use? or does it have to be 'info_1'?
    (double quote or single quote)

    You can use either kind of quote.

    But they must of course be nested correctly, eg

    "something='quoted'" or 'something="quoted"'

    not crossed over.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)