Search in the entire XML CategoryID Tree

Viewed 35

I'm trying to search the whole Entity-Tree for a CategoryID.

Currently I'm searching it like this:

/root/EntityHelpers/Category/Entity[EntityID = $CategoryID]/EntityName

The problem here is, that it only searches the first Level of ID's in the tree.

The tree looks like this and I should search all of the child nodes from The first Entity tag on:

 <EntityHelper>
    <Category>
        <Entity>
            <EntityID>1</EntityID>
            <EntityName>Test1</EntityName>
            <Entity>
                <EntityID>12</EntityID>
                <EntityName>Test2</EntityName>
            </Entity>
        </Entity>
            <Entity>
            <EntityID>2</EntityID>
            <EntityName>Test1</EntityName>
            <Entity>
                <EntityID>22</EntityID>
                <EntityName>Test2</EntityName>
            </Entity>
        </Entity>
    </Category>
</EntityHelper>

So if I want to search the CategoryID 1 it will return the name but if I search the CategoryID 12 it won't return anything.

Does anyone have an answer how to get it to work that both (1 and 12) will return their name?

1 Answers

I found a solution to the problem:

select="/root/EntityHelpers/Category//Entity[EntityID = $CategoryID]/Name">

// Selects all elements no matter where they are in the document

For me it was a different error on top of that one but it might help someone who has the same problem.

Related