0

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.

2 Answers 2

1

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

0

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

You must log in to answer this question.

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