Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

SelectSingleNode throwing exception:

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anup Daware - 31 Aug 2007 09:25 GMT
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
Patrick Steele - 03 Sep 2007 14:58 GMT
> Hi,
>
[quoted text clipped - 22 lines]
>     <m:MT_MaterialSearchRequest xmlns:m="http://br.eu/tl/v2">
>       <CUSTOMER/>

Its been a long time since I did this in an app.  I dug up the code but
I'm not sure it will work for you.  I had to add the namespace to the
NameTable property and then add it to the XmlNamespaceManager.  See if
this works:

requestXmlDocument.NameTable.Add("SOAP-ENV");
requestXmlDocument.NameTable.Add("m");

XmlNamespaceManager ns =
    new XmlNamespaceManager(requestXmlDocument.NameTable);
ns.AddNamespace("SOAP-ENV",
    "http://schemas.xmlsoap.org/soap/envelope/");
ns.AddNamespace("m", "http://br.eu/tl/v2");

Now, in all of your queries, use the overload that takes a namespace
manager.

Hope this helps.

Signature

Patrick Steele (patrick@mvps.org)
http://weblogs.asp.net/psteele


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.