I'm working through a Selenium test where I want to assert a particular HTML node is an exact match as far as what attributes are present and their values (order is unimportant) and also that no other attributes are present. For example given the following fragment: 
<input name="test" value="something"/>
I am trying to come up with the a good way of asserting its presence in the HTML output, such that the following (arbitrary) examples would not match:

<input name="test" value="something" onlick="doSomething()"/>
<input name="test" value="something" maxlength="75"/>
<input name="test" value="something" extraneous="a" unwanted="b"/>

I believe I can write an XPath statement as follows to find all of these, for example: 
//input[value='something' and @name='test'] 
But, I haven't figured out how to write in such a way that it excludes not exact matches in a generalize fashion. Note, it doesn't have to be an XPath solution, but that struck me as the most likely elegant possibility.
There is no way to exclude unexpected attributes with XPath.
So you must find a safer way to locate elements you want. Things that you should consider:

In a form, each input should have a distinct name. The same is true for the form itself. So you can try //form[@name='...']/input[@name='...']
Add a class to the fields that you care about. Classes don't have be mentioned in any stylesheet. In fact, I used this for form field validation by using classes like decimal number or alpha number
Finding Only HTML Nodes Whose Attributes Match Exactly