User1804449101 posted
My xml file Like below . It should <i:sample..... thing to be .
<?xml version="1.0" encoding="UTF-16"?>
<i:sample version="3.0" xmlns:i="urn:BlueSchema">
<Preview>
<Name><![CDATA[Tension method]]></Name>
</Preview>
</i:sample>
My code behind
string fileName = @"C:\ASTM D882-09 Bluehill 3 Method.IM_TENS";
XPathDocument doc = new XPathDocument(fileName);
XPathNavigator nav = doc.CreateNavigator();
// Compile a standard XPath expression
XPathExpression expr;
expr = nav.Compile("i:sample/Preview/Name");
XPathNodeIterator iterator = nav.Select(expr);
try
{
while (iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
string w = nav2.Value;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
But always getting error for i:sample prefix. if i use <sample> its working . But my xml is always containing that prefix