EDN Admin
Well-known member
Hi
I have xml that looks like this:
<Response xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema " ID="_3e70b91e-2b4a-4170-900d-9be5fb1e0e43"
Version="2.0" IssueInstant="2011-08-01T16:15:36.2645666Z" Destination="dbmotion.com" xmlns="urnasis:names:tc:SAML:2.0rotocol <br/>
<Issuer xmlns="urnasis:names:tc:SAML:2.0:assertion upmc.com</Issuer><br/>
<Status><br/>
<StatusCode Value="urnasis:names:tc:SAML:2.0:status:Success" /><br/>
</Status><br/>
<Assertion Version="2.0" ID="_063d7e1a-e69b-4ce3-8fe0-84396e3e27de" IssueInstant="2011-08-01T16:15:38.5045666Z" xmlns="urnasis:names:tc:SAML:2.0:assertion <br/>
<Issuer></Issuer><br/>
<Subject><br/>
<NameID NameQualifier="1upmc-acct </NameID><br/>
<SubjectConfirmation Method="urnasis:names:tc:SAML:2.0:cm:bearer <br/>
<SubjectConfirmationData NotOnOrAfter="2011-08-01T16:20:38.5445666Z" Recipient="dbmotion.com" /><br/>
</SubjectConfirmation><br/>
</Subject><br/>
<Conditions NotBefore="2011-08-01T16:15:38.5045666Z" NotOnOrAfter="2011-08-01T16:20:38.5045666Z <br/>
<AudienceRestriction><br/>
<Audience></Audience><br/>
</AudienceRestriction><br/>
</Conditions><br/>
<AuthnStatement AuthnInstant="2011-08-01T16:15:38.5045666Z <br/>
<AuthnContext><br/>
<AuthnContextClassRef>AuthnContextClassRef</AuthnContextClassRef><br/>
</AuthnContext><br/>
</AuthnStatement><br/>
<AttributeStatement><br/>
<Attribute Name="firstname" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="lastname" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="description" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="role" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="role" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
</AttributeStatement><br/>
</Assertion><br/>
</Response>
All I want to do is get the node at "//Assertion/Subject". This works fine in the query tool
I am trying to get said node this way with an XmlDocument passed to me as an argument:
XmlNodeList list = doc.SelectNodes("//Assertion/Subject");
List is always empty. If I try by single node I get null. I have tried many different flavours of this XPath to no avail. If I get the FirstChild then that Nodes childnode by ordinal I get results. if I XPath a wildcart ("*") I get
the root node but I cannot get a return in code. I know it is something small and stupid but any help would be great. I only need the node because I want the reference to it so I can insert a node in front of it - not a big task.
Many thanks!
<br/>
View the full article
I have xml that looks like this:
<Response xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd=" http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema " ID="_3e70b91e-2b4a-4170-900d-9be5fb1e0e43"
Version="2.0" IssueInstant="2011-08-01T16:15:36.2645666Z" Destination="dbmotion.com" xmlns="urnasis:names:tc:SAML:2.0rotocol <br/>
<Issuer xmlns="urnasis:names:tc:SAML:2.0:assertion upmc.com</Issuer><br/>
<Status><br/>
<StatusCode Value="urnasis:names:tc:SAML:2.0:status:Success" /><br/>
</Status><br/>
<Assertion Version="2.0" ID="_063d7e1a-e69b-4ce3-8fe0-84396e3e27de" IssueInstant="2011-08-01T16:15:38.5045666Z" xmlns="urnasis:names:tc:SAML:2.0:assertion <br/>
<Issuer></Issuer><br/>
<Subject><br/>
<NameID NameQualifier="1upmc-acct </NameID><br/>
<SubjectConfirmation Method="urnasis:names:tc:SAML:2.0:cm:bearer <br/>
<SubjectConfirmationData NotOnOrAfter="2011-08-01T16:20:38.5445666Z" Recipient="dbmotion.com" /><br/>
</SubjectConfirmation><br/>
</Subject><br/>
<Conditions NotBefore="2011-08-01T16:15:38.5045666Z" NotOnOrAfter="2011-08-01T16:20:38.5045666Z <br/>
<AudienceRestriction><br/>
<Audience></Audience><br/>
</AudienceRestriction><br/>
</Conditions><br/>
<AuthnStatement AuthnInstant="2011-08-01T16:15:38.5045666Z <br/>
<AuthnContext><br/>
<AuthnContextClassRef>AuthnContextClassRef</AuthnContextClassRef><br/>
</AuthnContext><br/>
</AuthnStatement><br/>
<AttributeStatement><br/>
<Attribute Name="firstname" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="lastname" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="description" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="role" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
<Attribute Name="role" NameFormat="urnasis:names:tc:SAML:2.0:attrname-format:basic <br/>
<AttributeValue xsi:type="xsd:string </AttributeValue><br/>
</Attribute><br/>
</AttributeStatement><br/>
</Assertion><br/>
</Response>
All I want to do is get the node at "//Assertion/Subject". This works fine in the query tool
I am trying to get said node this way with an XmlDocument passed to me as an argument:
XmlNodeList list = doc.SelectNodes("//Assertion/Subject");
List is always empty. If I try by single node I get null. I have tried many different flavours of this XPath to no avail. If I get the FirstChild then that Nodes childnode by ordinal I get results. if I XPath a wildcart ("*") I get
the root node but I cannot get a return in code. I know it is something small and stupid but any help would be great. I only need the node because I want the reference to it so I can insert a node in front of it - not a big task.
Many thanks!
<br/>
View the full article