XML: Find out node which doesn’t have a given attribute

Question: Find out a node which doesn't have a given attribute.
For e.g., in the given xml, get the third Child node which doesn’t have the attribute ‘name’.

<?xml version="1.0" encoding="UTF-8"?>
<Children>
	<Child name='A' />
	<Child name='B' />
	<Child />
	<Child age='30'/>
</Children>


XPath to find nodes without ‘name’ attribute
/Children/Child[not(@name)]


XPath to find nodes without ‘name’ and ‘age’ attribute
/Children/Child[not (@name) and not(@age)]

Comments

Popular posts from this blog

Wix: How to hide the License Agreement dialog in Mondo UI

WPF: TreeView example (Part 4)