Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find sub-children, but the document say it could! #46

Open
MatthD opened this issue Sep 9, 2023 · 0 comments
Open

Cannot find sub-children, but the document say it could! #46

MatthD opened this issue Sep 9, 2023 · 0 comments

Comments

@MatthD
Copy link

MatthD commented Sep 9, 2023

Hello

I have a simple XML loaded and parsed when I try to get an element via get_child it does not find it via get_child("infos") and return NONE, but the documentation say we can do it, or am I wrong ?

https://docs.rs/xmltree/latest/xmltree/struct.Element.html#method.get_child

My XML:

<!DOCTYPE article PUBLIC "my doctype of doom" "mydoctype.dtd">
<xpath>
    <to>
        <my>
            <infos attrib="example">trezaq</infos>
            <infosdust>23</infosdust>
        </my>
    </to>
</xpath>

Is there any way to not do something like this :

let infosdust = root_element.get_child("to").unwrap().get_child("my").unwrap().get_child("infos").unwrap().get_text().unwrap();
            assert_eq!(infosdust, "trezaq");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant