How to check if a node's value in one XML is present in another XML with a specific attribute?

Posted by Manish on Stack Overflow See other posts from Stack Overflow or by Manish
Published on 2010-06-03T10:25:41Z Indexed on 2010/06/03 10:34 UTC
Read the original article Hit count: 223

Filed under:
|
|

The question seems to be little confusing. So let me describe my situation through an example:

Suppose I have an XML: A.xml

<Cakes>
    <Cake>Egg</Cake>
    <Cake>Banana</Cake>
</Cakes>

Another XML: B.xml

<Cakes>
    <Cake show="true">Egg</Cake>
    <Cake show="true">Strawberry</Cake>
    <Cake show="false">Banana</Cake>
</Cakes>

Now I want to show some text say "TRUE" if all the Cake in A.xml have show="true" in B.xml else "FALSE".

In the above case, it will print FALSE.

I need to develop an XSL for that. I can loop through all the Cake in A.xml and check if that cake has show="true" in B.xml but I don't know how to break in between (and set a variable) if a show="false" is found.

Is it possible? Any help/comments appreciated.

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xslt