tags:

views:

31

answers:

1
var assets1 = data.SelectNodes("//asset[@id]=" + oldBinaryAssetId);
var assets2 = data.SelectNodes("//Asset[@id]=" + oldBinaryAssetId);

Is it possible to make 1 xpath query of the two above?

+3  A: 

Your XPath is wrong to be gin with. You probably mean:

data.SelectNodes("//Asset[@id = '" + oldBinaryAssetId + "']");

To combine both variants (upper- and lower-case), you could use:

data.SelectNodes("//*[(name() = 'Asset' or name() = 'asset') and @id = '" + oldBinaryAssetId + "']");

or

data.SelectNodes("(//Asset | //asset)[@id = '" + oldBinaryAssetId + "']");

If you have any way to avoid the // operator, I recommend doing so. Your queries will be faster when you do, though this might only be noticable with large input documents.

Tomalak
Yes, indeed, sorry for the mistake. Thx.
Lieven Cardoen