Skip to main content

get_node_attribute

Function get_node_attribute 

Source
pub fn get_node_attribute(node: &Node, key: &str) -> Option<String>
Expand description

Read a possibly-PREFIXED attribute off a node, resolving the prefix the same way Document::set_attribute does on the write side (via decode_qname).

libxml stores xml:id as local name id in the built-in xml namespace, and xmlGetProp matches on the plain name — so get_attribute("xml:id") finds NOTHING. That asymmetry is invisible in Rust bindings (which read ids through get_attribute_ns) but bites any caller that writes an attribute by qualified name and then tries to read it back by the same name, which is exactly what a script does after generateID.