Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

<parent1>
<parent2>
<parent3>
<element1>
my aim entry
</element1>
</parent3>
</parent2>
</parent1>

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:

parent1.parent2.parent3.element1

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.

share
add comment

2 Answers

up vote 1 down vote accepted

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

share
add comment

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
share
add comment

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .