Given an Xml document, how would you populate a list of paths of attributes and elements



Given the following Xml:



<Student number='2020'>
<Subject>Comp</Subject>
<Credintials>
<Password>010101</Password>
<PasswordLength>6</PasswordLength>
<Contact>contact@example.com</Contact>
</Credintials>
<PersonalDetails age='30' height='2'/>
<Lecture age='30' height='2'>
<StudentName>Hakeem</StudentName>
</Lecture>
</Student>


I would want to print out the following list:



Student.@number=2020
Student.Subject=Comp
Student.Credintials.Password=010101
Student.Credintials.PasswordLength=6
Student.Credintials.Contact=contact@example.com
Student.PersonalDetails.@age=30
Student.Lecture.@age=30
Student.PersonalDetails.@height=2
Student.Lecture.@height=2
Student.Lecture.StudentName=Hakeem


I am basically trying to get these paths for attributes and elements which have their values equal to the innerText, elements like StudentName, Password, Subject. atttributes like age, height etc


Thanks


No comments:

Post a Comment