xml:
<?xml version="1.0" encoding="utf-8" ?><EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
entityID="http://10.162.1.220:8082/bspcore">
<IDPSSODescriptor WantAuthnRequestsSigned="true"
protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"> <SingleSignOnService isDefault="true" index="0"
Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="http://10.162.1.220:8082/bspcore/SAML2/POST/SSO" /> <SingleSignOnServiceBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"Location="http://10.162.1.220:8082/bspcore/SAML2/REDIRECT/SSO" /> <ArtifactResolutionServiceBinding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP"
Location="http://10.162.1.220:8082/bspcore/SAML2/Artifact" /> <SingleLogoutServiceBinding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP"
Location="http://10.162.1.220:8082/bspcore/SAML2/SLO/SOAP" /> <SingleLogoutServiceBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"Location="http://10.162.1.220:8082/bspcore/SAML2/SLO/REDIRECT"
ResponseLocation="http://10.162.1.220:8082/bspcore/SAML2/SLO/Response" /> <NameIDFormat> urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName </NameIDFormat> <NameIDFormat> urn:oasis:names:tc:SAML:2.0:nameid-format:persistent </NameIDFormat> <NameIDFormat> urn:oasis:names:tc:SAML:2.0:nameid-format:transient </NameIDFormat> </IDPSSODescriptor></EntityDescriptor>
代码:
XElement idpdoc = XElement.Load(new StreamReader("E:\\IDP.xml"));
var test = idpdoc.Descendants("NameIDFormat");
var NameIdFormats = (from ni in idpdoc.Descendants() where ni.Name=="NameIDFormat" select ni.Value).ToList<String>();
结果:
test.Count()=0;
NameIdFormats .Count()=0;