Automation · Data Formats › XML
Attributes
Cheat sheet · https://pcornel.dk/topic.php?topic=5832
Answer
XML attributes are name-value pairs inside an element's start tag, such as <interface name="Gi1">. Use them for simple metadata and elements for content and nested data.
Remember
- Attributes are name-value pairs in start tags.
- Use them for metadata, elements for content.
- Select them with @name in XPath.
First checks
xmllint --xpath 'string(//element/@attr)' file.xml— read attribute- Attribute vs element choice — design
- Quoting and escaping — correctness
Verify in this order
element + attributes → data
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.
XML → Attributes · operational reference
| Layer | XML → Attributes operational reference |
|---|---|
| Runtime/ownership | XML 1.0 attributes and namespace-aware processing · identify controller/parser, durable intent, identity and target ownership before mutation |
| Persistent intent | Versioned definition/configuration with explicit dependencies, scope and credential boundary |
| Verification | Parse a namespaced XML fixture, inspect element expanded names plus attribute names/values, validate expected required/defaulted attributes where schema/DTD applies. |
| Expected interpretation | Attributes are attached to the intended element with correct namespace/name/value semantics, quoting/entity normalization is handled by the parser, and downstream automation does not confuse text/element data with attributes. |
| Recovery boundary | Preserve correlation IDs + pre-state, repair first failing boundary, then verify the target independently |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5832