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

need help of usage #24

Open
BH1SCW opened this issue Dec 9, 2022 · 0 comments
Open

need help of usage #24

BH1SCW opened this issue Dec 9, 2022 · 0 comments

Comments

@BH1SCW
Copy link

BH1SCW commented Dec 9, 2022

Here is some part of my html file:

{
 778                                       "name": "div",
 779                                       "variant": "normal",
 780                                       "classes": [
 781                                         "pl-3"
 782                                       ],
 783                                       "children": [
 784                                         {
 785                                           "name": "a",
 786                                           "variant": "normal",
 787                                           "attributes": {
 788                                             "href": "/rpms/asciidoc"
 789                                           },
 790                                           "children": [
 791                                             {
 792                                               "name": "div",
 793                                               "variant": "normal",
 794                                               "children": [
 795                                                 {
 796                                                   "name": "strong",
 797                                                   "variant": "normal",
 798                                                   "children": [
 799                                                     "rpms/asciidoc"
 800                                                   ]
 801                                                 }
 802                                               ]
 803                                             }
 804                                           ]
 805                                         },
 806                                         {
 807                                           "name": "div",
 808                                           "variant": "normal",
 809                                           "attributes": {
 810                                             "data-toggle": "tooltip",
 811                                             "title": " Text based document generation "
 812                                           },
 813                                           "children": [
 814                                             {
 815                                               "name": "small",
 816                                               "variant": "normal",
 817                                               "children": [
 818                                                 "Text based document generation"
 819                                               ]
 820                                             }
 821                                           ]
 822                                         }
 823                                       ]
 824                                     }
 825                                   ]
 826                                 },

I can get href : /rpms/asciidoc using following code:

    let hrefs = iter.filter_map(|item| match item {
        Node::Element(ref element) if element.name == "a" => element.attributes["href"].clone(),
        _ => None,
    });

but I also want to get this line: " Text based document generation "

I try this but not work, could you tell me how to modify it?

    let hrefs = iter.filter_map(|item| match item {
        Node::Element(ref element) if element.name == "div" => element.attributes["title"].clone(),
        _ => None,
    });

Thanks so much

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