C#: XML snippets

Parsing some namespaced XML


<Response xmlns="urn:oasis:names:tc:SAML:1.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol" IssueInstant="2009-07-03T04:11:19.354Z" MajorVersion="1" MinorVersion="1" ResponseID="ab05928dfbba21e829f4778f22c9ec3f">
    <StatusCode Value="samlp:Success"></StatusCode>


XmlDocument saml;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(saml.NameTable);
nsmgr.AddNamespace("saml", "urn:oasis:names:tc:SAML:1.0:protocol");
string status = saml.SelectSingleNode("saml:Response/saml:Status/saml:StatusCode/@Value", nsmgr).Value;

The End


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: