Search code examples
xmlxpathodooodoo-16

selecting element that is inside of an if statement xpath


What is the ideal way to select an element that is inside of if-else statements? For example, if in a qweb view, there is a statement that says something like:

t-if="something"

    <div>INFORMATION</div>

t-else-if="somethingElse"

    <div>SOME OTHER INFROMATION</div>

Now, what is the ideal way to write an XPath expression that modifies both? If I do //div[1] and then //div[2], it says it can't find the second element, which is true I guess because it'll only be there if the second condition is true. However, that'll also make it //div[1], no? But if I only do //div or //div[1], it doesn't affect the second one, even when the second condition is true. What am I missing here? 


Solution

  • Yes there is a better approach available, you can use this example below

    <xpath expr="//t[@t-if='something']" position="after">
    ....
    </xpath>