pub struct HtmlDocument { /* private fields */ }
Expand description
An HTML document that has been parsed into a virtual DOM.
Implementations§
Source§impl HtmlDocument
impl HtmlDocument
Sourcepub fn new(raw: String, dom: Html, is_fragment: bool) -> Self
pub fn new(raw: String, dom: Html, is_fragment: bool) -> Self
Create a new HtmlDocument
from a string of HTML and a Html
DOM.
raw
- The raw HTML string.dom
- The parsed HTML DOM.
Sourcepub fn from_str(html: String) -> Self
pub fn from_str(html: String) -> Self
Parse an HTML document from a string.
html
- The HTML string to parse.
Sourcepub fn find_all(&self, selector: &str) -> Result<Vec<HtmlNode>>
pub fn find_all(&self, selector: &str) -> Result<Vec<HtmlNode>>
Query the document for matching elements using a CSS selector..
selector
- The CSS selector to query for.
Sourcepub fn find_all_xpath(&self, xpath: &str) -> Result<Vec<XPathResult>>
pub fn find_all_xpath(&self, xpath: &str) -> Result<Vec<XPathResult>>
Query the document for matching elements using an XPath expression.
xpath
- The XPath expression to query for.
Sourcepub fn find(&self, selector: &str) -> Result<Option<HtmlNode>>
pub fn find(&self, selector: &str) -> Result<Option<HtmlNode>>
Query the document for the first matching element using a CSS selector.
selector
- The CSS selector to query for.
Sourcepub fn find_xpath(&self, xpath: &str) -> Result<Option<XPathResult>>
pub fn find_xpath(&self, xpath: &str) -> Result<Option<XPathResult>>
Query the document for the first matching element using an XPath expression.
xpath
- The XPath expression to query for.
Sourcepub fn find_nth(&self, selector: &str, n: usize) -> Result<Option<HtmlNode>>
pub fn find_nth(&self, selector: &str, n: usize) -> Result<Option<HtmlNode>>
Query the document for the nth matching element using a CSS selector.
selector
- The CSS selector to query for.n
- The index of the element to get.
Sourcepub fn find_nth_xpath(
&self,
xpath: &str,
n: usize,
) -> Result<Option<XPathResult>>
pub fn find_nth_xpath( &self, xpath: &str, n: usize, ) -> Result<Option<XPathResult>>
Query the document for the nth matching element using an XPath expression.
xpath
- The XPath expression to query for.n
- The index of the element to get.
Trait Implementations§
Source§impl Clone for HtmlDocument
impl Clone for HtmlDocument
Source§fn clone(&self) -> HtmlDocument
fn clone(&self) -> HtmlDocument
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for HtmlDocument
impl Debug for HtmlDocument
impl Send for HtmlDocument
impl Sync for HtmlDocument
Auto Trait Implementations§
impl Freeze for HtmlDocument
impl !RefUnwindSafe for HtmlDocument
impl Unpin for HtmlDocument
impl !UnwindSafe for HtmlDocument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more