what you are looking for is a xpath expression:
//NODE[@attribute1="characters" and ( not(@attribute2) or @attribute2="chr")]
quick test with xmllint:
kent$ cat f.xml
<root>
<NODE attribute1="characters" attribute2="chr" name="node1">
<content>
value1
</content>
</NODE>
<NODE attribute1="camera" name="node2">
<content>
value2
</content>
</NODE>
<NODE attribute1="camera" attribute2="car" name="node3">
<content>
value2
</content>
</NODE>
</root>
kent$ xmllint --xpath '//NODE[@attribute1="characters" and ( not(@attribute2) or @attribute2="chr")]' f.xml
<NODE attribute1="characters" attribute2="chr" name="node1">
<content>
value1
</content>
</NODE>
UPDATE
if you only want to extract the value of attribute name, you can use this xpath:
//NODE[@attribute1="characters" and ( not(@attribute2) or @attribute2="chr")]/@name
or
string(//NODE[@attribute1="characters" and ( not(@attribute2) or @attribute2="chr")]/@name)
still test with xmllint:
kent$ xmllint --xpath '//NODE[@attribute1="characters" and ( not(@attribute2) or @attribute2="chr")]/@name' f.xml
name="node1"
kent$ xmllint --xpath 'string(//NODE[@attribute1="characters" and ( not(@attribute2) or @attribute2="chr")]/@name)' f.xml
node1