xml.Html(doc : xml, xpath? : str) : xml
Extract the inner portion of xml nodes into a new xml document.
9.02 or later
| Name | Type | Description |
| source | doc | XML source document |
| xpath | str | (optional, default:none) Xpath of the element(s) to extract child nodes from |
The result is always a new document and since documents cannot have more than one root, the result is always wrapped in <html><body>...</body></html>, which is the default envelope for emitted xml from dekiscript. I.e. it is automatically stripped when inserted into Deki. When the xpath matches multiple elements, all child nodes of the matched elements are appended to the <html><body> document, but the matched node themselves are omitted.
| Dekiscript | Xml | Emitted on page |
| Inner Xml: | ||
{{xml.html(<div>"some ";<b>"text"</b></div>)}} | <html>
<body>
some <b>text</b>
</body>
</html>
| some text |
| Inner Xml of Xpath: | ||
{{xml.html(<ul><li>"a"</li><li><b>"b"</b></li></ul>, "li")}} | <html>
<body>
a
<b>b</b>
</body>
</html> | a b |
| Rewriting <ul> with <ol> | ||
var html = <div>
<p> 123 </p>
<p> 456 </p>
<p> 789 </p>
</div>;
xml.html(html, 'p'); | <html>
<body>
123456789
</body>
</html> | 123456789 |
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by