Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
Generalfish eye images converter Pin
doph5-May-04 8:34
doph5-May-04 8:34 
GeneralStrange TypeLoadException Pin
Broken God5-May-04 5:59
Broken God5-May-04 5:59 
GeneralRe: Strange TypeLoadException Pin
leppie5-May-04 6:52
leppie5-May-04 6:52 
GeneralRe: Strange TypeLoadException Pin
Anonymous5-May-04 7:47
Anonymous5-May-04 7:47 
GeneralRemoving event listeners on IHTMLDocument2 objects Pin
agking5-May-04 5:56
agking5-May-04 5:56 
GeneralDLL Help Pin
goldoche5-May-04 5:54
goldoche5-May-04 5:54 
GeneralRe: DLL Help Pin
Heath Stewart5-May-04 6:59
protectorHeath Stewart5-May-04 6:59 
GeneralXmlDocument, SOAP& Namespaces Pin
MrEyes5-May-04 5:40
MrEyes5-May-04 5:40 
I have the following SOAP data (which I have no control over):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Logon xmlns="http://www.domain.com/EP/">
      <userId>int</userId>
      <strPassword>string</strPassword>
      <strSessionId>string</strSessionId>
    </Logon>
  </soap:Body>
</soap:Envelope>


I need to be able to parse through this to extract the childnode values of <Logon>, and place these into a sorted list. Simple I thought, but namespaces are causing me some problems :

SortedList GetLogonData(string soapData)
{
	XmlDocument soapDataXdoc = new XmlDocument();
	soapDataXdoc.LoadXml(soapData);

	XmlNamespaceManager nsMgr = new XmlNamespaceManager(soapDataXdoc.NameTable);
	nsMgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
	nsMgr.AddNamespace("", "http://www.domain.com/EP/");

	XmlNode logonNode = soapDataXdoc.SelectSingleNode("soap:Envelope/soap:Body/Logon", nsMgr);

	SortedList returnValue = new SortedList();
	foreach(XmlNode xn in logonNode.ChildNodes)
	{
		returnValue.Add(xn.Name, xn.InnerText);
	}

	return returnValue;
}


In theory this should return a sorted list with the following values

userId - int
strPassword - string
strSessionId - session


But when I retrieve the logonNode this returns null, which I believe is being caused by an incorrect xpath, but I do not know why it is incorrect.

Could anybody point me in the right direction?


post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
GeneralRe: XmlDocument, SOAP&amp; Namespaces Pin
Heath Stewart5-May-04 5:44
protectorHeath Stewart5-May-04 5:44 
GeneralRe: XmlDocument, SOAP& Namespaces Pin
MrEyes5-May-04 5:58
MrEyes5-May-04 5:58 
GeneralRe: XmlDocument, SOAP&amp; Namespaces Pin
Heath Stewart5-May-04 7:10
protectorHeath Stewart5-May-04 7:10 
GeneraldataGridTextBoxColumn textBox Pin
blankg5-May-04 5:16
blankg5-May-04 5:16 
Generalc# Listbox help Pin
John Baird5-May-04 4:48
John Baird5-May-04 4:48 
GeneralRe: c# Listbox help Pin
Heath Stewart5-May-04 4:59
protectorHeath Stewart5-May-04 4:59 
GeneralRe: c# Listbox help Pin
John Baird5-May-04 9:21
John Baird5-May-04 9:21 
GeneralRe: c# Listbox help Pin
Heath Stewart5-May-04 9:31
protectorHeath Stewart5-May-04 9:31 
GeneralCreating &amp; Using DLL's Pin
Lakshmikanthan5-May-04 4:42
Lakshmikanthan5-May-04 4:42 
GeneralRe: Creating &amp; Using DLL's Pin
Heath Stewart5-May-04 4:55
protectorHeath Stewart5-May-04 4:55 
GeneralDiffgrams and Web Services Pin
MrJJKoolJ5-May-04 3:51
MrJJKoolJ5-May-04 3:51 
GeneralRe: Diffgrams and Web Services Pin
Heath Stewart5-May-04 4:13
protectorHeath Stewart5-May-04 4:13 
GeneralRe: Diffgrams and Web Services Pin
MrJJKoolJ5-May-04 5:08
MrJJKoolJ5-May-04 5:08 
GeneralRe: Diffgrams and Web Services Pin
Heath Stewart5-May-04 5:16
protectorHeath Stewart5-May-04 5:16 
GeneralRe: Diffgrams and Web Services Pin
MrJJKoolJ5-May-04 5:23
MrJJKoolJ5-May-04 5:23 
GeneralRe: Diffgrams and Web Services Pin
Heath Stewart5-May-04 5:25
protectorHeath Stewart5-May-04 5:25 
GeneralRe: Diffgrams and Web Services Pin
MrJJKoolJ5-May-04 5:51
MrJJKoolJ5-May-04 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.