Try this out (assuming you mean mi
elements by saying NodeToExtract
):
XElement doc = XElement.Parse(@"<?xml version=""1.0"" encoding=""ISO-8859-1""?><mdc><ne><neun>ADB</neun><nn>SubNetwork=Context</nn><nw>R33</nw><mi><nut>20140101</nut><hq>000</hq><nw><npid>Text to Find</npid><r>0</r></nw></mi></ne><ofid><ofun>ABC</ofun><ofdn>Blah</ofdn><ofsw>18R</ofsw></ofid><mi><mts>More Blah</mts><gp>000</gp><mu>Value1</mu><mu>Value2</mu><mu>Value3</mu><mu>Value4</mu><mu>Value5</mu><nw><npid>ABC1221</npid><r>99</r><r>0</r><r>0</r><r>0</r><r>0</r></nw><nw><npid>ABC1222</npid><r>99</r><r>0</r><r>0</r><r>0</r><r>0</r></nw><nw><npid>ABC1223</npid><r>99</r><r>0</r><r>0</r><r>0</r><r>0</r></nw></mi></mdc>");
IEnumerable<XElement> query1 = doc.Descendants("npid").Where(c => c.Value == "Text to Find").Ancestors("mi");
IEnumerable<XElement> query2 = query1.First().Parent.ElementsAfterSelf("mi");
dynamic resut_node = new XElement("result");
resut_node.Add(query1.First());
resut_node.Add(query2.First());
Console.Write(resut_node.ToString());
UPDATE
XElement doc = XElement.Parse(@"<?xml version=""1.0"" encoding=""ISO-8859-1""?>
<mdc>
<ne>
<neun>ADB</neun>
<nn>SubNetwork=Context</nn>
<nw>R33</nw>
<mi>
<nut>20140101</nut>
<hq>000</hq>
<nw>
<npid>Text to Find</npid>
<r>0</r>
</nw>
</mi>
</ne>
<ofid>
<ofun>ABC</ofun>
<ofdn>Blah</ofdn>
<ofsw>18R</ofsw>
</ofid>
<NodeToExtract>
<mts>More Blah</mts>
<gp>000</gp>
<mu>Value1</mu>
<mu>Value2</mu>
<mu>Value3</mu>
<mu>Value4</mu>
<mu>Value5</mu>
<nw>
<npid>ABC1221</npid>
<r>99</r>
<r>0</r>
<r>0</r>
<r>0</r>
<r>0</r>
</nw>
<nw>
<npid>ABC1222</npid>
<r>99</r>
<r>0</r>
<r>0</r>
<r>0</r>
<r>0</r>
</nw>
<nw>
<npid>ABC1223</npid>
<r>99</r>
<r>0</r>
<r>0</r>
<r>0</r>
<r>0</r>
</nw>
</NodeToExtract>
</mdc>");
IEnumerable<XElement> query1 = doc.Descendants("npid").Where(c => c.Value == "Text to Find").Ancestors("mi");
IEnumerable<XElement> query2 = query1.First().Parent.ElementsAfterSelf("NodeToExtract");
Console.Write(query2.First().ToString());