Automation · Data Formats › XML
Parsing
Cheat sheet · https://pcornel.dk/topic.php?topic=5834
Answer
Parse XML with a proper library — [xml] or Select-Xml in PowerShell, lxml or ElementTree in Python — taking care of namespaces, which NETCONF replies always use.
Remember
- Use [xml], Select-Xml, lxml or ElementTree.
- Register namespaces before querying.
- Avoid regex for XML.
First checks
python3 -c 'import defusedxml.ElementTree as ET;ET.parse("f.xml")'— safe parsexmllint --noout --nonet file.xml— no network entity loading- XXE protections enabled — security
Verify in this order
XML → safe parser → tree
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5834