Reputation: 4410
I am parsing the XML in C# this XML:
<Resident Type="R">
<Payment>1218</Payment>
</Resident>
I am parsing this way(please answer this same way, not other methods)
XmlDocument parsed_xml = new XmlDocument();
parsed_xml.LoadXml(dto.xml);
XmlNodeList test = parsed_xml.SelectNodes("/IER/Credit/Loan/LoanApp/Applicant/Personal/Individuals/Individual/Resident/Peyment");
if (xnList != null)
PAYMENT = xnList.Item(0).InnerText;
with this code I can get the Payment value that is 1218 but how I can get the attribute value of Type that is "R" ?
Upvotes: 1
Views: 9157
Reputation: 3111
You'll want to look at the ParentNode
to get the attribute.
string residentType = xnList[0].ParentNode.Attributes["Type"].Value;
Upvotes: 3