help with selecting nodes with xpath

Posted by fayer on Stack Overflow See other posts from Stack Overflow or by fayer
Published on 2010-03-23T21:59:27Z Indexed on 2010/03/23 22:03 UTC
Read the original article Hit count: 236

Filed under:
|

my xml structure looks like this:

<entity id="1000070">
    <name>apple</name>
    <type>category</type>
    <entities>
        <entity id="7002870">
            <name>mac</name>
            <type>category</type>
            <entities>
                <entity id="7002907">
                    <name>leopard</name>
                    <type>sub-category</type>
                    <entities>
                        <entity id="7024080">
                            <name>safari</name>
                            <type>subject</type>
                        </entity>
                        <entity id="7024701">
                            <name>finder</name>
                            <type>subject</type>
                        </entity>
                    </entities>
                </entity>
            </entities>
        </entity>
        <entity id="7024080">
            <name>iphone</name>
            <type>category</type>
            <entities>
                <entity id="7024080">
                    <name>3g</name>
                    <type>sub-category</type>
                </entity>
                <entity id="7024701">
                    <name>3gs</name>
                    <type>sub-category</type>
                </entity>
            </entities>
        </entity>
        <entity id="7024080">
            <name>ipad</name>
            <type>category</type>
        </entity>
    </entities>
</entity>

currently i have selected all entities with type node that is not category.

$xmlDocument->removeNodes("//entity[not(type='category')]")

i wonder how i could select all nodes that dont contain type=category OR type=sub-category.

i have tried with:

$xmlDocument->removeNodes("//entity[not(type='category')] | //entity[not(type='sub-category')]")

but it doesnt work!

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xpath