Closed Random-G closed 2 years ago
@Random-G the behavior of the html()
and text()
method just follow the jquery
do, i don't know why jquery
design like that, because sometimes it's indeed confusing. now if you want to get the combined html of all the elements, you may do like this:
let html = "<div><span>1<span></div><div><span>2</span></div>";
let root = Vis::load(html)?;
let divs = root.find("div");
let all_div_html = divs.map(|_, ele| ele.html()).join(""); // <span>1<span><span>2</span>
it need to write some more code, if it's a common need, maybe we can add a sugar method html_all()
or other names whaterver for this purpose, do you have any good idea?
@fefit Thank you very much for your response. html_all()
or htmls()
sounds good.
@Random-G htmls()
sounds great! i will append the htmls()
and outer_htmls()
methods in the new version, thanks for your advice and feedback!
the new version v0.5.6 has published to resolve this~
@fefit Thank you very much for the update.
Hello, I'd like to get all elements with html tags and attribute. The currently available methods are .html() and .outer_html(). However, these methods only target the first element. The .text() gets all the elements in plain text. Is there a way to achieve this purpose with html?