SelectSingleNode throwing exception:

Discussion in 'ASP .Net' started by Anup Daware, Aug 31, 2007.

  1. Anup Daware

    Anup Daware Guest

    Hi,
    I have following XML which I need to modify and invoke a http request
    I need to select a node but I am getting "Namespace Manager or
    XsltContext needed. This query has a prefix, variable, or user-defined
    function." Error
    I am trying to access the <CUSTOMER/> tag with following code:


    requestXmlDocument.SelectSingleNode("/SOAP-ENV:Envelope/SOAP-ENV:Body/
    m:MT_MaterialSearchRequest/" + XmlNodeName.CUSTOMER).InnerText
    = some value;

    Please consider following tags before giving answer:
    · <SOAP-ENV:Envelope
    · <SOAP-ENV:Body
    · <m:MT_MaterialSearchRequest


    Following is the Xml:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
    envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
    <m:MT_MaterialSearchRequest xmlns:m="http://br.eu/tl/v2">
    <CUSTOMER/>
    <SALES_ORG/>
    <DISTR_CHAN/>
    <DIVISION/>
    <SEARCH_RESULT_SIZE/>
    <DEFAULT_SORTING/>
    <RESULT_TYPE>R</RESULT_TYPE>
    <REQ_DATE/>
    <REQ_QTY/>
    <SALES_UNIT/>
    <SEARCH_PARAM_IN>
    <AGG_SEARCH/>
    <COMMERCIAL_CODE/>
    <DESCRIPTION/>
    <WIDTH/>
    <SERIE/>
    <RIM/>
    <LOAD_INDEX/>
    <SPEED_SYMBOL/>
    <PATTERN/>
    <TUBE_TYPE/>
    <BRAND/>
    <HIERARCHY/>
    </SEARCH_PARAM_IN>
    <VISIBILITY_ITEM_IN>
    <ITEM>
    <ITM_NUMBER/>
    <MATERIAL idtype=""/>
    <REQ_QTY/>
    <SALES_UNIT/>
    <REQ_DATE/>
    </ITEM>
    </VISIBILITY_ITEM_IN>
    </m:MT_MaterialSearchRequest>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    I think I have to use XmlNamespaceManager, but I am not getting how do
    I use it in this case when there are following three tags in the
    xmldocument.
    · <SOAP-ENV:Envelope
    · <SOAP-ENV:Body
    · <m:MT_MaterialSearchRequest



    Thanks in advance,
    Anup
     
    Anup Daware, Aug 31, 2007
    #1
    1. Advertising

  2. Anup Daware

    bruce barker Guest

    if you nodes have a namespace, you need to pass the namespace manger
    along with the path

    XmlNamespceManger ns = new XmlNamespceManger(
    requestXmlDocument.NameTable);
    ns.AddNamespace("SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/");
    ns.AddNamespace("m","http://br.eu/tl/v2");
    requestXmlDocument.SelectSingleNode(
    "/SOAP-ENV:Envelope/SOAP-ENV:Body/m:MT_MaterialSearchRequest/" +
    XmlNodeName.CUSTOMER,
    ns).InnerText = some value;

    -- bruce (sqlwork.com)

    Anup Daware wrote:
    > Hi,
    > I have following XML which I need to modify and invoke a http request
    > I need to select a node but I am getting "Namespace Manager or
    > XsltContext needed. This query has a prefix, variable, or user-defined
    > function." Error
    > I am trying to access the <CUSTOMER/> tag with following code:
    >
    >
    > requestXmlDocument.SelectSingleNode("/SOAP-ENV:Envelope/SOAP-ENV:Body/
    > m:MT_MaterialSearchRequest/" + XmlNodeName.CUSTOMER).InnerText
    > = some value;
    >
    > Please consider following tags before giving answer:
    > · <SOAP-ENV:Envelope
    > · <SOAP-ENV:Body
    > · <m:MT_MaterialSearchRequest
    >
    >
    > Following is the Xml:
    >
    > <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
    > envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    > <SOAP-ENV:Body>
    > <m:MT_MaterialSearchRequest xmlns:m="http://br.eu/tl/v2">
    > <CUSTOMER/>
    > <SALES_ORG/>
    > <DISTR_CHAN/>
    > <DIVISION/>
    > <SEARCH_RESULT_SIZE/>
    > <DEFAULT_SORTING/>
    > <RESULT_TYPE>R</RESULT_TYPE>
    > <REQ_DATE/>
    > <REQ_QTY/>
    > <SALES_UNIT/>
    > <SEARCH_PARAM_IN>
    > <AGG_SEARCH/>
    > <COMMERCIAL_CODE/>
    > <DESCRIPTION/>
    > <WIDTH/>
    > <SERIE/>
    > <RIM/>
    > <LOAD_INDEX/>
    > <SPEED_SYMBOL/>
    > <PATTERN/>
    > <TUBE_TYPE/>
    > <BRAND/>
    > <HIERARCHY/>
    > </SEARCH_PARAM_IN>
    > <VISIBILITY_ITEM_IN>
    > <ITEM>
    > <ITM_NUMBER/>
    > <MATERIAL idtype=""/>
    > <REQ_QTY/>
    > <SALES_UNIT/>
    > <REQ_DATE/>
    > </ITEM>
    > </VISIBILITY_ITEM_IN>
    > </m:MT_MaterialSearchRequest>
    > </SOAP-ENV:Body>
    > </SOAP-ENV:Envelope>
    >
    >
    > I think I have to use XmlNamespaceManager, but I am not getting how do
    > I use it in this case when there are following three tags in the
    > xmldocument.
    > · <SOAP-ENV:Envelope
    > · <SOAP-ENV:Body
    > · <m:MT_MaterialSearchRequest
    >
    >
    >
    > Thanks in advance,
    > Anup
    >
     
    bruce barker, Aug 31, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    503
  2. Martin
    Replies:
    0
    Views:
    2,444
    Martin
    Nov 14, 2005
  3. Richard Saville

    can not get selectSingleNode to compile

    Richard Saville, Jan 16, 2005, in forum: Java
    Replies:
    3
    Views:
    733
    Martin Honnen
    Jan 17, 2005
  4. Replies:
    3
    Views:
    2,495
    Chris Smith
    Mar 28, 2006
  5. dushkin
    Replies:
    9
    Views:
    923
    Andrew Thompson
    Aug 23, 2006
Loading...

Share This Page