XU XUv0.8.8
EN

API

#html/query

import: #html/query

counts: 1 函数, 6 方法, 2 类型, 0 常量, 0 方法集

标准库包 `#html/query`。

struct Attr

XuAPI
pub struct Attr {
    pub key string
    pub value string
}

用途

公开结构体 `Attr`。

参数

key string
键
value string
字段(string)

struct Doc

XuAPI
pub struct Doc {
    pub tags []string
    pub texts []string
    pub firsts []int
    pub nexts []int
    pub parents []int
    pub attr_keys []string
    pub attr_vals []string
    pub attr_next []int
    pub attr_head []int
}

用途

公开结构体 `Doc`。

参数

tags []string
字段([]string)
texts []string
字段([]string)
firsts []int
字段([]int)
nexts []int
字段([]int)
parents []int
字段([]int)
attr_keys []string
字段([]string)
attr_vals []string
字段([]string)
attr_next []int
字段([]int)
attr_head []int
字段([]int)

parse

XuAPI
pub fn parse(html0 string) Doc

用途

解析输入。

参数

html0 string
html0(string)

返回

Doc — 该类型的值

(&Doc) root

XuAPI
pub fn (d &Doc) root() int

用途

在 `&Doc` 上调用 `root`。

参数

d &Doc
接收者 &Doc(借用)

返回

int — 该类型的值

(&Doc) tag

XuAPI
pub fn (d &Doc) tag(n int) string

用途

`&Doc` 上的方法:标签。

参数

d &Doc
接收者 &Doc(借用)
n int
数量、长度或上限(int)

返回

string — 结果字符串

(&Doc) attr

XuAPI
pub fn (d &Doc) attr(n int, key string) string

用途

在 `&Doc` 上调用 `attr`。

参数

d &Doc
接收者 &Doc(借用)
n int
数量、长度或上限(int)
key string
键(string)

返回

string — 结果字符串

(&Doc) text_content

XuAPI
pub fn (d &Doc) text_content(n int) string

用途

`&Doc` 上的方法:文本content。

参数

d &Doc
接收者 &Doc(借用)
n int
数量、长度或上限(int)

返回

string — 结果字符串

(&Doc) query_all

XuAPI
pub fn (d &Doc) query_all(selector string) []int

用途

`&Doc` 上的方法:查询串all。

参数

d &Doc
接收者 &Doc(借用)
selector string
selector(string)

返回

[]int — 切片结果

(&Doc) query

XuAPI
pub fn (d &Doc) query(selector string) int

用途

`&Doc` 上的方法:查询串。

参数

d &Doc
接收者 &Doc(借用)
selector string
selector(string)

返回

int — 该类型的值