tags:

views:

19

answers:

1

`

XElement config = XElement.Parse (
@"<Response SessionId='426D9AEB1F684849A16D79A6CF48582B' xmlns='http://schemas.tmaresources.com/timssws60.xsd'&gt;
<Status Success='true' Message='Connected' ErrorCode='0' />
</Response>");

XElement response = config.Element("Response");

sessionID = (string)response.Attribute("SessionId");`

why is response null in this case? how can I get the attribute value SessionId?

+1  A: 

Your config variable contains the <Response> element itself.
Calling config.Element("Response") will try to get a <Response> element inside the <Response> element.
Since there isn't any, it returns null.

Change it to

(string)config.Attribute("SessionId")
SLaks
Thanks! Works great!!
Kalls