I have a large (10k lines) XML file. Normally i use Notepad++ or Chrome to open XML files. Although it is possible to collapse/uncollapse child entries, i can't see which element has which parents.

For example:

my aim entry

Every time i want to check parents of element1 i check upper lines, collapse/uncollapse them to find out that actual heritage is like this:


Is it possible to find this heritage by a program? Because i do this job for this big XML file every week and sometimes I make errors and all system breaks.


Good XML editors will have this future, one that's used by IBM for instance is oxygen.


If you have xmllint (should be on Linux/OS X by default, otherwise here), just do:

xmllint --shell your-xml-file.xml

Then formulate the following XPath query:

xpath //element1/ancestor::*

The result would be:

Object is a Node Set :
Set contains 3 nodes:
1  ELEMENT parent1
2  ELEMENT parent2
3  ELEMENT parent3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.