XPATH - determining missing attribute

G

Grant Merwitz

Hi, i'm not sure if this is the appropriate topic.
But here goes:

I am currently bulding a site menu from a xml file.
I have an attribute that indicates whether an option is active or not
"isactive=true/false"
Now using xpath it is easy to filter this out:

Xpath="MainBar/Section[@isactive="true"]

Now, i want to add a new attribute saying "isadmin=true/false", and this
will only display these values if an admin is logged in,
Now i'm struggling to find how to hide these if an admin is NOT logged in.
This attribute will not be there if this is a NON admin menu option.
I.e.:

<Section name="Option1" />
<Section name="Option2" isadmin="true" />

Now, how do I filter out the admin options using XPath.
(show nodes where the isadmin attribute is not present)
I've tried the following with no success:

Xpath="MainBar/Section[@isadmin=""]
Xpath="MainBar/Section[@isadmin=null]

I've googled around with no success,
Is there a way to say "where this attribute is not present"?
I don't want to add an "isadmin=false" to every node applicable.

TIA for any help
 
M

Martin Honnen

Grant said:
Now, how do I filter out the admin options using XPath.
(show nodes where the isadmin attribute is not present)
I've tried the following with no success:

Xpath="MainBar/Section[@isadmin=""]

Use
Mainbar/Section[not(@isadmin)]
 
G

Grant Merwitz

worked like a charm.

thanks so much for your help!

Martin Honnen said:
Grant said:
Now, how do I filter out the admin options using XPath.
(show nodes where the isadmin attribute is not present)
I've tried the following with no success:

Xpath="MainBar/Section[@isadmin=""]

Use
Mainbar/Section[not(@isadmin)]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top