1

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" ?

3

1 Answer 1

3

You'll want to look at the ParentNode to get the attribute.

string residentType = xnList[0].ParentNode.Attributes["Type"].Value;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.