atc0005 / learn

Various topics that I want to learn more about, either for professional development or for my own use
0 stars 0 forks source link

XML | XPath #90

Open atc0005 opened 4 years ago

atc0005 commented 4 years ago

Background

I'm using (or trying to use) XPath with the atc0005/go-lockss project. That project processes a LOCKSS XML configuration file served up by a central network configuration server and then attempts to verify connectivity from the current node (where the app is running) to all peer nodes.

As part of this work, I've stumbled my way through using the https://github.com/antchfx/xmlquery package to process the XML file and retrieve the values I'm looking for. I thought I understood what was happening, but as atc0005/go-lockss#21 notes, I'm not getting the expected results.

In short, there is a bug with the application and I'm not (yet) knowledgeable enough to fix it properly. Thankfully the app's assumptions work as intended for two of the LOCKSS networks that I've tested against, but more work is needed to properly parse the XML file to work with other networks where group-based peers are configured.

Parsing that file will require a better understanding of XPath than I currently have.

What I've found

Guides

Videos

Tools

atc0005 commented 4 years ago

Notes below were taken while watching the 9. XPath examples and demonstrations in XML video.

The plants.xml file was the sample XML document used by Brandon Jones (GitHub, YouTube) in the XPath examples shown in the video.

plants.xml file ```xml Cercis canadensis Eastern Redbud 25 2017-03-15 2017-03-30 true full_sun violet 39.47 -84.51 Brandan Jones Beautiful tree! 52.40 1.00 Joe Bloggs RBG Kew -22.50 -68.25 Guillermo Sanchez Lovely Specimen! -25.50 38.25 Dave Jones wonderful Specimen! ```

Other tools used in the video:


Examples pulled 1:1 from Notepad++ screenshot:

My scratch notes:

atc0005 commented 4 years ago

I picked up this bit (watched this video before Brandon Jones' video series where he also covered this) from the XPath Basics Tutorial HD video.

This (incomplete) syntax:

food[@name='tacos']

indicates that you want to filter the food elements by the name=tacos attribute:

<food name="tacos">

The video is relatively short, but gave a great overview. The free XML Quire application is used in the examples.