473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XPATH - determining missing attribute

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
Mar 15 '07 #1
2 2062
Grant Merwitz wrote:
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)]


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 15 '07 #2
worked like a charm.

thanks so much for your help!

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:uY*************@TK2MSFTNGP05.phx.gbl...
Grant Merwitz wrote:
>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)]


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Mar 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
9
by: Iain | last post by:
I want to create an XML configuration file which might look like <REGION Name="Europe" WingDing="Blue"> <COUNTRY Name="UK" WingDing="white"> <TOWN Name="London" WingDing="Orange" /> </COUNTRY>...
3
by: Kevin | last post by:
I know this has probably been discussed many times before (I found answers when I searched yesterday), but I still can't get it to work... I have an attribute @OID that can contain any...
2
by: David Gordon | last post by:
Hi Folks, I wonder if anyone can help me with the following (perhaps trivial) problem: <xml> <node name="a" type="a"/> <node name="b" type=""/> <node name="c"/> <node name="d" type="b"/>...
3
by: richlm | last post by:
I use node.SelectNode(...) to locate a particular element/attribute in my document. If it doesn't exist I get a null reference. Is there a simple way to create the "missing" element/attribute...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
3
by: SD | last post by:
Hi, How can i get all the nodes with attribute Name = "Publisher" or Name="Administrator" using XPath query and C# for this xml doc? <GetRoleCollectionFromUser...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.