[xquery-talk] how can I compare each node with it's prior node

Ronald Bourret rpbourret at rpbourret.com
Fri May 6 08:18:32 PDT 2011


You should also consider restructuring your XML so that it is clear 
which price belongs to which item. For example:

<comp-abc>
<dept1>
    <item price="124">abc</item>
    <item price="56">xyz</item>
</dept1>
...
</comp-abc>

or:

<comp-abc>
<dept1>
    <item>
       <name>abc</name>
       <price>124</price>
    </item>
    <item>
       <name>xyz</name>
       <price>56</price>
    </item>
</dept1>
...
</comp-abc>

-- Ron


Kunal Chauhan wrote:
> Hi,
>  
> I want to check which node is above the price node. I want that node.
>  
>  
> Thanks
> 
> On Fri, May 6, 2011 at 12:45 PM, Andrew Welch <andrew.j.welch at gmail.com 
> <mailto:andrew.j.welch at gmail.com>> wrote:
> 
>     On 6 May 2011 07:40, Kunal Chauhan <mail4ck at gmail.com
>     <mailto:mail4ck at gmail.com>> wrote:
>      > Hi,
>      >
>      > I have a document like
>      >
>      > <comp-abc>
>      >
>      > <dept1>
>      >          <item>abc</item>
>      >          <price>124</price>
>      >          <item>xyz</item>
>      >           <price>56</price>
>      > </dept1>
>      >
>      > <dept2>
>      >           <item>abc</item>
>      >           <price>124</price>
>      >           <item>xyz</item>
>      >            <price>56</price>
>      > </dept2>
>      >
>      > </comp-abc>
>      >
>      > Now I want to chekc whether all price nodes are followed by item
>     only.
>      > How can I check this ?
> 
> 
>     price/following-sibling::*[1][self:item]
> 
>     (your xml suggests item should be followed by price, but your
>     description asks for the other way around...)
> 
> 
>     --
>     Andrew Welch
>     http://andrewjwelch.com
> 
> 
> 
> 
> -- 
> *Kunal Chauhan*
> mail4ck at gmail.com <mailto:mail4ck at gmail.com>
> [+918655517141]
> [+919904983614]
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
> 
> 
> ------------------------------------------------------------------------
> 
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 10.0.1321 / Virus Database: 1500/3618 - Release Date: 05/05/11
> 


More information about the talk mailing list