我想从以下 XML 中获得负载
<t:RequestSecurityTokenResponse xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<t:RequestedSecurityToken>
<Assertion ID="_a2baec61-1e5a-4f7e-8cc4-44ca3cb82a44" IssueInstant="2012-10-30T11:56:19.211Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
<Issuer>https://vidizmo1-ac.accesscontrol.windows.net/</Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<ds:Reference URI="#_a2baec61-1e5a-4f7e-8cc4-44ca3cb82a44">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<ds:DigestValue>XsW696+Y/CkArU5a8zvqeEckl+rpgiv0lEEs2PDx3Hw=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
</ds:Signature>
**<AttributeStatement>
<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
<AttributeValue>farooqtest11@gmail.com</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name">
<AttributeValue>farooq test</AttributeValue>
</Attribute>
<Attribute Name="http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider">
<AttributeValue>Google</AttributeValue>
</Attribute>
</AttributeStatement>**
</Assertion>
</t:RequestedSecurityToken>
<t:TokenType>urn:oasis:names:tc:SAML:2.0:assertion</t:TokenType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
</t:RequestSecurityTokenResponse>
我的代码是:
string xml = @"C:\Users\baseer.haider\Documents\visual studio 2010\Projects\CheckReadXML\CheckReadXML\ACS.xml";
XmlDocument acsXml = new XmlDocument();
acsXml.Load(xml);
XmlNodeList acsNode = acsXml.DocumentElement.SelectNodes("//AttributeStatement//Attribute");
foreach (XmlNode node in acsNode)
{
if (node.Attributes["Name"] != null)
{
if (node.Attributes["Name"].Value == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")
{
var innerNode = node.SelectSingleNode("//AttributeValue");
Console.WriteLine(innerNode.InnerText);
}
}
我想从以下 XML 加载节点,但我无法加载它,因为当我使用此代码选择该节点时 XmlNodeList acsNode =acsXml.DocumentElement.SelectNodes("//AttributeStatement//Attribute");
acsNode 为空。任何人都可以解决这个问题吗?