First - you should provide just uri for namespace:
nsmgr.AddNamespace("ns", "http://schemas.microsoft.com/wix/2006/objects");
Second - you should use namespace when providing node name. And table has attribute name
instead of type
:
XmlNodeList nodeList = root.SelectNodes("//ns:table[@name='XFile']/ns:row", nsmgr);
And last - after selecting row nodes, you should select fourth field node (which has full name ns:field
):
foreach (XmlNode row in nodeList)
{
XmlNode field = row.SelectSingleNode("(ns:field)[4]", nsmgr);
Console.WriteLine("Field: {0}", field.InnerText);
}
Output:
Field: This line here 1
Field: This line here 2
NOTE: You can get fields directly, without looping on rows:
XmlNodeList fields =
root.SelectNodes("//ns:table[@name='XFile']/ns:row/ns:field[4]", nsmgr);