Skip to content

string(@attr) returns element text instead of attribute value #20

Description

@ancientcatz

I found what looks like an XPath evaluation bug in the xmllint implementation from xmloxide.

This works correctly with libxml2's xmllint:

curl -sL https://news.ycombinator.com | xmllint --html --xpath "string((//span[@class='titleline']/a)[1]/@href)" -

Output:

https://ratty-term.org/

But the xmloxide implementation returns the anchor text instead:

curl -sL https://news.ycombinator.com | xmllint-rs --html --xpath "string((//span[@class='titleline']/a)[1]/@href)" -

Output:

Ratty – A terminal emulator with inline 3D graphics

(xmllint-rs above is just the local alias I use for the xmloxide version to avoid confusion with libxml2's xmllint.)

Expected behavior is for the XPath expression to evaluate to the attribute value (href), not the text content of the <a> element.

Looks like attribute node handling during string() conversion may be incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions