cleanup, docs
This commit is contained in:
@@ -21,32 +21,12 @@ Try the live example in the [XML demo](../demo/xml.uce).
|
||||
|
||||
Return shape:
|
||||
|
||||
```text
|
||||
node["name"] = element name
|
||||
node["attrs"] = map of attributes
|
||||
node["text"] = text content when non-empty
|
||||
node["children"] = list of child element nodes
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```uce
|
||||
DValue book = xml_decode("<book id=\"b1\"><title>UCE & XML</title></book>");
|
||||
|
||||
book["name"].to_string(); // book
|
||||
book["attrs"]["id"].to_string(); // b1
|
||||
book["children"]["0"]["name"].to_string(); // title
|
||||
book["children"]["0"]["text"].to_string(); // UCE & XML
|
||||
```
|
||||
|
||||
CDATA and numeric entities are folded into text:
|
||||
|
||||
```uce
|
||||
DValue note = xml_decode("<note><![CDATA[5 < 6]]><symbol>AB</symbol></note>");
|
||||
|
||||
note["text"].to_string(); // 5 < 6
|
||||
note["children"]["0"]["text"].to_string(); // AB
|
||||
```
|
||||
|
||||
Supported parser features:
|
||||
|
||||
@@ -61,3 +41,7 @@ Supported parser features:
|
||||
Whitespace-only text between child elements is ignored. Mixed non-empty text is concatenated into `node["text"]`.
|
||||
|
||||
Malformed XML raises a request-visible runtime error.
|
||||
|
||||
:example
|
||||
DValue node = xml_decode("<root><name>Ada</name></root>");
|
||||
print(node.is_array() ? "xml\n" : "empty\n");
|
||||
|
||||
Reference in New Issue
Block a user