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?
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.
精彩评论