Sandip
Sandip

Reputation: 3751

XML - SelectNodes - How to get nodes with attribute with some value (MFC)

I am working in MFC

I would like to get all nodes from XML , with attribute with some value but value should not be null, and should not select node if no attribute present

<node att="sss"> - should be selected
<node att="sd342ss"> - should be selected
<node att=""> - empty value should not be selected
<node > - not having attribute should not be selected

how to create XPATH for this?

Upvotes: 0

Views: 1155

Answers (1)

Anthill
Anthill

Reputation: 1249

Given a structure like:

<root>
    <node att="sss" />
    <node att="sd342ss" /> 
    <node att="" />
    <node />
</root>

Your XPath to select only nodes which have an attribute and where the attribute's value is not empty would look something like:

"//node[@att and string-length(@att) > 0]"

Upvotes: 1

Related Questions