XPath find an empty attribute

Hello group,

How can I find the node <b> that contains the empty name attribute?
   <b name="" code="0">
   <b name="somename" code="0">
I'm using XPath with XMLDocument
 DOMNode := RXMLDoc.SelectNode('//a/b[@name=""']');

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
you have the correct Xpath in your question
I prefer this
DOMNode := RXMLDoc.SelectNode('//a/b[string-length(normalize-space(@name)) = 0]');

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
charlesgates22Author Commented:
thank you very much for your response,
yes, it's working now.

so you like using string-length(normalize-space(@name)) = 0]'
how come? what's the danger in just using "" ?
what if I have one common code and I pass the atttribute name to find, so sometime this parameter can be empty and sometime can actually contain a string, either way I need to find the correspondent node, what's the best practice?
DOMNode := RXMLDoc.SelectNode('//a/b[@name="' + parpassed + '"']');
parpassed can be "" or "somename"

Geert BormansInformation ArchitectCommented:
> how come? what's the danger in just using "" ?

there is no danger, but I explicitely exclude attributes containing only whitespace as well this way

your example with parpassed should work
charlesgates22Author Commented:
Gertone, BTW congrats for your annual EE award!
Geert BormansInformation ArchitectCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.