KWARC / rust-libxml

Rust wrapper for libxml2
https://crates.io/crates/libxml
MIT License
76 stars 38 forks source link

Missing the ability to get an attribute with no namespace #125

Closed anwaralameddin closed 8 months ago

anwaralameddin commented 8 months ago

Using the current Node API, it does not seem always possible to retrieve the value of a property with no namespace when multiple properties have the same local name.

The method get_property returns the value of the first property with a given local name, regardless of namespace; it cannot retrieve the value of the nonprefixed property bar in the node below when ns:bar and bar appear in this order:

<foo xmlns:ns="http://example.com" ns:bar="NS BAR" bar="bar" />

The library already provides two methods, get_property_ns and get_property, that utilise xmlGetNsProp and xmlGetProp, respectively. I think I need a third, say get_property_no_ns, that similarly utilises xmlGetNoNsProp.

Please let me know if this can already be achieved differently.

dginev commented 8 months ago

I think you are making a very reasonable suggestion, and get_property_no_ns continues the existing pattern.

If you feel like making a PR, I'm happy to accept it.

anwaralameddin commented 8 months ago

Thank you! While writing the test, I noticed the same issue for remove_attribute. That, it removes the first property regardless of namespace. However, it is unclear to me whether the needed bindings exist to address this. Anyway, It could be better handled separately.