Read mini program element fields
mp_element_readRead multiple fields (text, value, attributes, styles, WXML, custom data) from one Mini Program element in a single call, distinguishing missing attributes from empty values.
Instructions
Read one or more fields from one element of the current page. Every field is read in a single call to avoid a round trip per attribute. Attribute, property and style reads report present separately from the value, so a missing attribute is distinguishable from an empty one. Custom component data (via data_path) and whole-element WXML are available too.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"selector": "<selector>",
"read": "<read>"
},
"name": "mp_element_read"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Attribute, property or style name used by attribute/property/style. | |
| read | Yes | Fields to read. text/value/size/offset/wxml work on any element; data needs a custom component; attribute/property/style need `name`. | |
| index | No | Zero-based match to use when the selector hits several elements. Defaults to 0. | |
| xpath | No | Treat selector as XPath. Not allowed together with container_selector. | |
| selector | Yes | WXML/CSS selector for the element, e.g. ".submit" or "view.title". | |
| data_path | No | Path inside a custom component data object, e.g. "form.name". | |
| container_selector | No | Resolve this selector first, then search inside it. When set, xpath must be false. |