site/contents/reference-xml.md
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
-----
content-type: "page"
title: "xml Module"
-----
{@ _defs_.md || 0 @}
{#op||cdata||{{sl}}||{{xcdata}}||
Returns a {{xcdata}} representing an XML CDATA section. #}
{#op||comment||{{sl}}||{{xcomment}}||
Returns a {{xcomment}} representing an XML comment. #}
{#op||element||{{sl}}||{{xelement}}||
Returns a {{xelement}} representing an XML element (it will be an empty element with no attributes or children). #}
{#op||entity||{{sl}}||{{xentity}}||
Returns a {{xentity}} representing an XML entity. #}
{#op||entity2utf8||{{xentity}}||{{s}}||
> Returns the UTF-8 symbol corresponding to the specified XML entity.
>
> > %sidebar%
> > Example
> >
> > The following program prints `p` to the screen:
> >
> > ">" xml.entity xml.entity2utf8 puts!
#}
{#op||escape||{{sl}}||{{s}}||
Converts any `<`, `>`, `&`, `'`, and `"` present in {{sl}} into the corresponding XML entities. #}
{#op||from-html||{{sl}}||{{xnode}}||
Returns an {{xnode}} representing an HTML string (wrapped in a `<document>` tag unless a valid HTML document is provided as input).#}
{#op||from-xml||{{sl}}||{{xnode}}||
> Returns an {{xnode}} representing an XML string (element or fragment).
>
> > %sidebar%
> > Example
> >
> > The following program:
> >
> > "<a href='https://min-lang.org'>min web site</a>" from-xml
> > returns the following:
> >
> > {
> > {"https://min-lang.org" :href} :attributes
> > ({"min web site" :text}) :children
> > "a" :tag
> > ;xml-element
> > }
#}
{#op||query||{{xelement}} {{sl}}||{{xelement}}||
> Returns an {{xelement}} representing the first element matching CSS the selector {{sl}}.
>
> > %sidebar%
> > Example
> >
> > The following program:
> >
> > "<ul>
> > <li class='test'>first</li>
> > <li class='other'>second</li>
> > <li class='test'>third</li>
> > </ul>"
> > xml.from-xml ".test" xml.query
> > Returns the following:
> >
> > {
> > {"test" :class} :attributes
> > ({"first" :text}) :children
> > "li" :tag
> > ;xml-element
> > }
#}
{#op||query-all||{{xelement}} {{sl}}||{{xelement}}||
> Returns a list of {{xelement}} dictionaries representing all the elements matching CSS the selector {{sl}}.
>
> > %sidebar%
> > Example
> >
> > The following program:
> >
> > "<ul>
> > <li class='test'>first</li>
> > <li class='other'>second</li>
> > <li class='test'>third</li>
> > </ul>"
> > xml.from-xml ".test" xml.queryall
> > Returns the following:
> >
> > ({
> > {"test" :class} :attributes
> > ({"first" :text}) :children
> > "li" :tag
> > ;xml-element
> > }
> > {
> > {"test" :class} :attributes
> > ({"third" :text}) :children
> > "li" :tag
> > ;xml-element
> > })
#}
{#op||text||{{sl}}||{{xtext}}||
Returns a {{xtext}} representing an XML text node. #}
{#op||to-xml||{{xnode}}||{{s}}||
Returns a {{s}} representing an XML node. #}
|