Started as a question on Stack Overflow a couple of years ago but now gets used often enough to keep around.
- A way to generate xpaths from an XML file, I use xmlstarlet
- This xpath2dot awk script.
- A way to directly view (xdot), or convert to image a Graphviz dot file
Starting with a XML file which might change or go away from
ftp://ftp.ncbi.nlm.nih.gov/pub/clinvar/xml/sample_xml/RCV000077146.xml
wget -q ftp://ftp.ncbi.nlm.nih.gov/pub/clinvar/xml/sample_xml/RCV000077146.xml
Which I will keep a snapshot of here.
xmlstarlet el -u RCV000077146.xml | xpath2dot.awk | dot -T png > xpath2dot_demo.png
Include XML attributes and change orientation to vertical
xmlstarlet el -a RCV000077146.xml | sort -u | \
xpath2dot.awk -v ORIENT="UD" | dot -T png > xpath2dot_demo_att.png