ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

How to extract tree hierarchy in xml?

(1/2) > >>

kalos:
Hello!

You know that xml files are hierarchical, ie there is a top level attribute, then sub-attributes are indented and so on.

How can I copy the hierarchy, ie the upper level attributes of a selected attribute/line?

For example:

<a>
     <1>
     <2>
           <x1>
           <x2>

I want to select x2 and copy the hierarchy of it, ie the upper level attributes that x2 belongs to:
<a>
     <2>


Any idea?

Thanks!

f0dder:
If this is something you're going to need often, you can look into XSLT - it lets you transform XML files in pretty flexibly ways.

It's pretty clunky to work with, though, so if you need a quick solution for a specific problem, there's probably easier ways.

kalos:
Thanks, as for now, is there an XML reader that can extract the hierarchy tree of a specific line?

Ath:
is there an XML reader that can extract the hierarchy tree of a specific line?
-kalos (July 30, 2018, 09:55 AM)
--- End quote ---
I use Notepad++ with plug-ins "XML Tools" and "Npp XML Treeview". The XML Tools plug-in has a nice and quick formatting feature (Ctrl-Alt-Shift-B), XPath expression evaluation and it shows the path to the current node when pressing Ctrl-Alt-Shift-P. With the treeview plug-in you can see the structure of the xml nodes (but not the attributes), and quickly select a node.

If that doesn't suffice, there's always XML Copy Editor, an open source specialized XML editor with a lot of features, including XSLT and XPath support. I hardly use it but it does offer some features not easily available in Notepad++ with it's plug-ins.

wraith808:
You could also use an online one.

https://codebeautify.org/xmlviewer

Navigation

[0] Message Index

[#] Next page

Go to full version