locked
Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function. RRS feed

  • Question

  • 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

    Wednesday, February 6, 2013 12:58 AM

All replies

  • User3866881 posted

    Hi,

    Which part of value do you want to fetch?

    Is this:

    <![CDATA[Tension method]]>

    Thursday, February 7, 2013 8:21 PM
  • User1804449101 posted

    first that error is passing in

    <i:sample version="3.0" xmlns:i="urn:BlueSchema">

    it dosent read "i" .

    Thursday, February 14, 2013 12:59 AM
  • User3866881 posted

    msbsam

    Hi again,

    Just tell me in simple:

    1) What do you wanna do?

    2) What acutally happens?

    3) What value do you wanna fetch?

    Thursday, February 14, 2013 5:15 AM