using System.Collections.Generic;
public static void Main()
var attrs = new Dictionary<string, string>
var result = XpathQueryBuilder(node, attrs);
Console.WriteLine(result);
private static string XpathQueryBuilder(string NodeName, Dictionary<string,string> attributes = null)
String.Join(" and ", attributes.Select(o =>
var attrVal = o.Value ?? "*";
return "@" + o.Key + "='" + attrVal + "'";
return "//" + NodeName + XpathAttr;