charlesgates22
asked on
XPath find an empty attribute
Hello group,
How can I find the node <b> that contains the empty name attribute?
<a>
<b name="" code="0">
</a>
<a>
<b name="somename" code="0">
</a>
I'm using XPath with XMLDocument
DOMNode := RXMLDoc.SelectNode('//a/b[ @name=""'] ');
Thanks.
How can I find the node <b> that contains the empty name attribute?
<a>
<b name="" code="0">
</a>
<a>
<b name="somename" code="0">
</a>
I'm using XPath with XMLDocument
DOMNode := RXMLDoc.SelectNode('//a/b[
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> 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
there is no danger, but I explicitely exclude attributes containing only whitespace as well this way
your example with parpassed should work
ASKER
Gertone, BTW congrats for your annual EE award!
thanks
ASKER
yes, it's working now.
so you like using string-length(normalize-sp
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?
e.g.:
DOMNode := RXMLDoc.SelectNode('//a/b[
parpassed can be "" or "somename"