2. Special characters

Sometimes issues appear with handling of special characters, where 'special' means in XML sence as well as in 'shell' terms. Examples below should clear at least some of the confusions.

You should not forget about the fact that your command lines are executed by shell and shell does substitutions of its special characters too. So for example, one may ask:

"Why does the following query return nothing?"

echo '<X name="foo">EEE</X>' | xml sel -t -m /X[@name='foo'] -v .

The answer lies in the way shell substitues 'foo', which simply becomes foo before the command is run. So the correct way to write that would be

echo '<X name="foo">EEE</X>' | xml sel -t -m "/X[@name='foo']" -v .

Another example involves XML special characters. Question: How to search for &apos; in text nodes?

The following should help

xml sel -t -m "//line[contains(text(),&quot;'&quot;)]" -c .