xmltree.html 165 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/xmltree</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/xmltree</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li>
  50. <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
  51. </li>
  52. <li>
  53. <details open>
  54. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  55. <ul class="simple simple-toc-section">
  56. <li><a class="reference" href="#XmlAttributes" title="XmlAttributes = StringTableRef">XmlAttributes</a></li>
  57. <li><a class="reference" href="#XmlNode" title="XmlNode = ref XmlNodeObj">XmlNode</a></li>
  58. <li><a class="reference" href="#XmlNodeKind" title="XmlNodeKind = enum
  59. xnText, ## a text element
  60. xnVerbatimText, xnElement, ## an element with 0 or more children
  61. xnCData, ## a CDATA node
  62. xnEntity, ## an entity (like ``&amp;thing;``)
  63. xnComment ## an XML comment">XmlNodeKind</a></li>
  64. </ul>
  65. </details>
  66. </li>
  67. <li>
  68. <details open>
  69. <summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
  70. <ul class="simple simple-toc-section">
  71. <li><a class="reference" href="#xmlHeader" title="xmlHeader = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot; ?&gt;\n&quot;">xmlHeader</a></li>
  72. </ul>
  73. </details>
  74. </li>
  75. <li>
  76. <details open>
  77. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  78. <ul class="simple simple-toc-section">
  79. <ul class="simple nested-toc-section">$
  80. <li><a class="reference" href="#%24%2CXmlNode" title="`$`(n: XmlNode): string">`$`(n: XmlNode): string</a></li>
  81. </ul>
  82. <ul class="simple nested-toc-section">[]
  83. <li><a class="reference" href="#%5B%5D%2CXmlNode%2Cint_2" title="`[]`(n: var XmlNode; i: int): var XmlNode">`[]`(n: var XmlNode; i: int): var XmlNode</a></li>
  84. <li><a class="reference" href="#%5B%5D%2CXmlNode%2Cint" title="`[]`(n: XmlNode; i: int): XmlNode">`[]`(n: XmlNode; i: int): XmlNode</a></li>
  85. </ul>
  86. <ul class="simple nested-toc-section">add
  87. <li><a class="reference" href="#add%2CXmlNode%2CXmlNode" title="add(father, son: XmlNode)">add(father, son: XmlNode)</a></li>
  88. <li><a class="reference" href="#add%2CXmlNode%2CopenArray%5BXmlNode%5D" title="add(father: XmlNode; sons: openArray[XmlNode])">add(father: XmlNode; sons: openArray[XmlNode])</a></li>
  89. <li><a class="reference" href="#add%2Cstring%2CXmlNode%2Cint%2Cint" title="add(result: var string; n: XmlNode; indent = 0; indWidth = 2; addNewLines = true)">add(result: var string; n: XmlNode; indent = 0; indWidth = 2; addNewLines = true)</a></li>
  90. </ul>
  91. <ul class="simple nested-toc-section">addEscaped
  92. <li><a class="reference" href="#addEscaped%2Cstring%2Cstring" title="addEscaped(result: var string; s: string)">addEscaped(result: var string; s: string)</a></li>
  93. </ul>
  94. <ul class="simple nested-toc-section">attr
  95. <li><a class="reference" href="#attr%2CXmlNode%2Cstring" title="attr(n: XmlNode; name: string): string">attr(n: XmlNode; name: string): string</a></li>
  96. </ul>
  97. <ul class="simple nested-toc-section">attrs
  98. <li><a class="reference" href="#attrs%2CXmlNode" title="attrs(n: XmlNode): XmlAttributes">attrs(n: XmlNode): XmlAttributes</a></li>
  99. </ul>
  100. <ul class="simple nested-toc-section">attrs=
  101. <li><a class="reference" href="#attrs%3D%2CXmlNode%2CXmlAttributes" title="attrs=(n: XmlNode; attr: XmlAttributes)">attrs=(n: XmlNode; attr: XmlAttributes)</a></li>
  102. </ul>
  103. <ul class="simple nested-toc-section">attrsLen
  104. <li><a class="reference" href="#attrsLen%2CXmlNode" title="attrsLen(n: XmlNode): int">attrsLen(n: XmlNode): int</a></li>
  105. </ul>
  106. <ul class="simple nested-toc-section">child
  107. <li><a class="reference" href="#child%2CXmlNode%2Cstring" title="child(n: XmlNode; name: string): XmlNode">child(n: XmlNode; name: string): XmlNode</a></li>
  108. </ul>
  109. <ul class="simple nested-toc-section">clear
  110. <li><a class="reference" href="#clear%2CXmlNode" title="clear(n: var XmlNode)">clear(n: var XmlNode)</a></li>
  111. </ul>
  112. <ul class="simple nested-toc-section">clientData
  113. <li><a class="reference" href="#clientData%2CXmlNode" title="clientData(n: XmlNode): int">clientData(n: XmlNode): int</a></li>
  114. </ul>
  115. <ul class="simple nested-toc-section">clientData=
  116. <li><a class="reference" href="#clientData%3D%2CXmlNode%2Cint" title="clientData=(n: XmlNode; data: int)">clientData=(n: XmlNode; data: int)</a></li>
  117. </ul>
  118. <ul class="simple nested-toc-section">delete
  119. <li><a class="reference" href="#delete%2CXmlNode%2CNatural" title="delete(n: XmlNode; i: Natural)">delete(n: XmlNode; i: Natural)</a></li>
  120. <li><a class="reference" href="#delete%2CXmlNode%2CSlice%5Bint%5D" title="delete(n: XmlNode; slice: Slice[int])">delete(n: XmlNode; slice: Slice[int])</a></li>
  121. </ul>
  122. <ul class="simple nested-toc-section">escape
  123. <li><a class="reference" href="#escape%2Cstring" title="escape(s: string): string">escape(s: string): string</a></li>
  124. </ul>
  125. <ul class="simple nested-toc-section">findAll
  126. <li><a class="reference" href="#findAll%2CXmlNode%2Cstring" title="findAll(n: XmlNode; tag: string; caseInsensitive = false): seq[XmlNode]">findAll(n: XmlNode; tag: string; caseInsensitive = false): seq[XmlNode]</a></li>
  127. <li><a class="reference" href="#findAll%2CXmlNode%2Cstring%2Cseq%5BXmlNode%5D" title="findAll(n: XmlNode; tag: string; result: var seq[XmlNode];
  128. caseInsensitive = false)">findAll(n: XmlNode; tag: string; result: var seq[XmlNode];
  129. caseInsensitive = false)</a></li>
  130. </ul>
  131. <ul class="simple nested-toc-section">innerText
  132. <li><a class="reference" href="#innerText%2CXmlNode" title="innerText(n: XmlNode): string">innerText(n: XmlNode): string</a></li>
  133. </ul>
  134. <ul class="simple nested-toc-section">insert
  135. <li><a class="reference" href="#insert%2CXmlNode%2CXmlNode%2Cint" title="insert(father, son: XmlNode; index: int)">insert(father, son: XmlNode; index: int)</a></li>
  136. <li><a class="reference" href="#insert%2CXmlNode%2CopenArray%5BXmlNode%5D%2Cint" title="insert(father: XmlNode; sons: openArray[XmlNode]; index: int)">insert(father: XmlNode; sons: openArray[XmlNode]; index: int)</a></li>
  137. </ul>
  138. <ul class="simple nested-toc-section">kind
  139. <li><a class="reference" href="#kind%2CXmlNode" title="kind(n: XmlNode): XmlNodeKind">kind(n: XmlNode): XmlNodeKind</a></li>
  140. </ul>
  141. <ul class="simple nested-toc-section">len
  142. <li><a class="reference" href="#len%2CXmlNode" title="len(n: XmlNode): int">len(n: XmlNode): int</a></li>
  143. </ul>
  144. <ul class="simple nested-toc-section">newCData
  145. <li><a class="reference" href="#newCData%2Csinkstring" title="newCData(cdata: sink string): XmlNode">newCData(cdata: sink string): XmlNode</a></li>
  146. </ul>
  147. <ul class="simple nested-toc-section">newComment
  148. <li><a class="reference" href="#newComment%2Csinkstring" title="newComment(comment: sink string): XmlNode">newComment(comment: sink string): XmlNode</a></li>
  149. </ul>
  150. <ul class="simple nested-toc-section">newElement
  151. <li><a class="reference" href="#newElement%2Csinkstring" title="newElement(tag: sink string): XmlNode">newElement(tag: sink string): XmlNode</a></li>
  152. </ul>
  153. <ul class="simple nested-toc-section">newEntity
  154. <li><a class="reference" href="#newEntity%2Cstring" title="newEntity(entity: string): XmlNode">newEntity(entity: string): XmlNode</a></li>
  155. </ul>
  156. <ul class="simple nested-toc-section">newText
  157. <li><a class="reference" href="#newText%2Csinkstring" title="newText(text: sink string): XmlNode">newText(text: sink string): XmlNode</a></li>
  158. </ul>
  159. <ul class="simple nested-toc-section">newVerbatimText
  160. <li><a class="reference" href="#newVerbatimText%2Csinkstring" title="newVerbatimText(text: sink string): XmlNode">newVerbatimText(text: sink string): XmlNode</a></li>
  161. </ul>
  162. <ul class="simple nested-toc-section">newXmlTree
  163. <li><a class="reference" href="#newXmlTree%2Csinkstring%2CopenArray%5BXmlNode%5D%2CXmlAttributes" title="newXmlTree(tag: sink string; children: openArray[XmlNode];
  164. attributes: XmlAttributes = nil): XmlNode">newXmlTree(tag: sink string; children: openArray[XmlNode];
  165. attributes: XmlAttributes = nil): XmlNode</a></li>
  166. </ul>
  167. <ul class="simple nested-toc-section">rawTag
  168. <li><a class="reference" href="#rawTag%2CXmlNode" title="rawTag(n: XmlNode): string">rawTag(n: XmlNode): string</a></li>
  169. </ul>
  170. <ul class="simple nested-toc-section">rawText
  171. <li><a class="reference" href="#rawText%2CXmlNode" title="rawText(n: XmlNode): string">rawText(n: XmlNode): string</a></li>
  172. </ul>
  173. <ul class="simple nested-toc-section">replace
  174. <li><a class="reference" href="#replace%2CXmlNode%2CNatural%2CopenArray%5BXmlNode%5D" title="replace(n: XmlNode; i: Natural; replacement: openArray[XmlNode])">replace(n: XmlNode; i: Natural; replacement: openArray[XmlNode])</a></li>
  175. <li><a class="reference" href="#replace%2CXmlNode%2CSlice%5Bint%5D%2CopenArray%5BXmlNode%5D" title="replace(n: XmlNode; slice: Slice[int]; replacement: openArray[XmlNode])">replace(n: XmlNode; slice: Slice[int]; replacement: openArray[XmlNode])</a></li>
  176. </ul>
  177. <ul class="simple nested-toc-section">tag
  178. <li><a class="reference" href="#tag%2CXmlNode" title="tag(n: XmlNode): lent string">tag(n: XmlNode): lent string</a></li>
  179. </ul>
  180. <ul class="simple nested-toc-section">tag=
  181. <li><a class="reference" href="#tag%3D%2CXmlNode%2Csinkstring" title="tag=(n: XmlNode; tag: sink string)">tag=(n: XmlNode; tag: sink string)</a></li>
  182. </ul>
  183. <ul class="simple nested-toc-section">text
  184. <li><a class="reference" href="#text%2CXmlNode" title="text(n: XmlNode): lent string">text(n: XmlNode): lent string</a></li>
  185. </ul>
  186. <ul class="simple nested-toc-section">text=
  187. <li><a class="reference" href="#text%3D%2CXmlNode%2Csinkstring" title="text=(n: XmlNode; text: sink string)">text=(n: XmlNode; text: sink string)</a></li>
  188. </ul>
  189. <ul class="simple nested-toc-section">toXmlAttributes
  190. <li><a class="reference" href="#toXmlAttributes%2Cvarargs%5Btuple%5Bstring%2Cstring%5D%5D" title="toXmlAttributes(keyValuePairs: varargs[tuple[key, val: string]]): XmlAttributes">toXmlAttributes(keyValuePairs: varargs[tuple[key, val: string]]): XmlAttributes</a></li>
  191. </ul>
  192. </ul>
  193. </details>
  194. </li>
  195. <li>
  196. <details open>
  197. <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
  198. <ul class="simple simple-toc-section">
  199. <ul class="simple nested-toc-section">items
  200. <li><a class="reference" href="#items.i%2CXmlNode" title="items(n: XmlNode): XmlNode">items(n: XmlNode): XmlNode</a></li>
  201. </ul>
  202. <ul class="simple nested-toc-section">mitems
  203. <li><a class="reference" href="#mitems.i%2CXmlNode" title="mitems(n: var XmlNode): var XmlNode">mitems(n: var XmlNode): var XmlNode</a></li>
  204. </ul>
  205. </ul>
  206. </details>
  207. </li>
  208. <li>
  209. <details open>
  210. <summary><a class="reference reference-toplevel" href="#17" id="67">Macros</a></summary>
  211. <ul class="simple simple-toc-section">
  212. <ul class="simple nested-toc-section"><>
  213. <li><a class="reference" href="#%3C%3E.m%2Cuntyped" title="`&lt;&gt;`(x: untyped): untyped">`&lt;&gt;`(x: untyped): untyped</a></li>
  214. </ul>
  215. </ul>
  216. </details>
  217. </li>
  218. </ul>
  219. </div>
  220. <div class="nine columns" id="content">
  221. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  222. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  223. <div id="tocRoot"></div>
  224. <p class="module-desc">A simple XML tree generator.
  225. <p><strong class="examples_text">Example:</strong></p>
  226. <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">xmltree</span>
  227. <span class="Keyword">var</span> <span class="Identifier">g</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  228. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;some text&quot;</span><span class="Punctuation">)</span>
  229. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;this is comment&quot;</span><span class="Punctuation">)</span>
  230. <span class="Keyword">var</span> <span class="Identifier">h</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;secondTag&quot;</span><span class="Punctuation">)</span>
  231. <span class="Identifier">h</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;some entity&quot;</span><span class="Punctuation">)</span>
  232. <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  233. <span class="Keyword">let</span> <span class="Identifier">k</span> <span class="Operator">=</span> <span class="Identifier">newXmlTree</span><span class="Punctuation">(</span><span class="StringLit">&quot;treeTag&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Identifier">g</span><span class="Punctuation">,</span> <span class="Identifier">h</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">att</span><span class="Punctuation">)</span>
  234. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;treeTag key1=&quot;first value&quot; key2=&quot;second value&quot;&gt;
  235. &lt;myTag&gt;some text&lt;!-- this is comment --&gt;&lt;/myTag&gt;
  236. &lt;secondTag&gt;&amp;some entity;&lt;/secondTag&gt;
  237. &lt;/treeTag&gt;&quot;&quot;&quot;</span></pre><strong>See also:</strong><ul class="simple"><li><a class="reference external" href="xmlparser.html">xmlparser module</a> for high-level XML parsing</li>
  238. <li><a class="reference external" href="parsexml.html">parsexml module</a> for low-level XML parsing</li>
  239. <li><a class="reference external" href="htmlgen.html">htmlgen module</a> for html code generator</li>
  240. </ul>
  241. </p>
  242. <div class="section" id="6">
  243. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  244. <dl class="item">
  245. <a class="reference external" href="since.html">since</a>, <a class="reference external" href="macros.html">macros</a>, <a class="reference external" href="strtabs.html">strtabs</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="sequtils.html">sequtils</a>, <a class="reference external" href="assertions.html">assertions</a>
  246. </dl>
  247. </div>
  248. <div class="section" id="7">
  249. <h1><a class="toc-backref" href="#7">Types</a></h1>
  250. <dl class="item">
  251. <div id="XmlAttributes">
  252. <dt><pre><a href="xmltree.html#XmlAttributes"><span class="Identifier">XmlAttributes</span></a> <span class="Other">=</span> <a href="strtabs.html#StringTableRef"><span class="Identifier">StringTableRef</span></a></pre></dt>
  253. <dd>
  254. <p>An alias for a string to string mapping.</p>
  255. <p>Use <a class="reference external" href="#toXmlAttributes,varargs[tuple[string,string]]">toXmlAttributes proc</a> to create <tt class="docutils literal"><span class="pre"><span class="Identifier">XmlAttributes</span></span></tt>.</p>
  256. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L54" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  257. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L54" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  258. </dd>
  259. </div>
  260. <div id="XmlNode">
  261. <dt><pre><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Identifier">XmlNodeObj</span></pre></dt>
  262. <dd>
  263. <p>An XML tree consisting of XML nodes.</p>
  264. <p>Use <a class="reference external" href="#newXmlTree,string,openArray[XmlNode],XmlAttributes">newXmlTree proc</a> for creating a new tree.</p>
  265. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L41" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  266. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L41" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  267. </dd>
  268. </div>
  269. <div id="XmlNodeKind">
  270. <dt><pre><a href="xmltree.html#XmlNodeKind"><span class="Identifier">XmlNodeKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  271. <span class="Identifier">xnText</span><span class="Other">,</span> <span class="Comment">## a text element</span>
  272. <span class="Identifier">xnVerbatimText</span><span class="Other">,</span> <span class="Identifier">xnElement</span><span class="Other">,</span> <span class="Comment">## an element with 0 or more children</span>
  273. <span class="Identifier">xnCData</span><span class="Other">,</span> <span class="Comment">## a CDATA node</span>
  274. <span class="Identifier">xnEntity</span><span class="Other">,</span> <span class="Comment">## an entity (like ``&amp;thing;``)</span>
  275. <span class="Identifier">xnComment</span> <span class="Comment">## an XML comment</span></pre></dt>
  276. <dd>
  277. Different kinds of XML nodes.
  278. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L46" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  279. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L46" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  280. </dd>
  281. </div>
  282. </dl>
  283. </div>
  284. <div class="section" id="10">
  285. <h1><a class="toc-backref" href="#10">Consts</a></h1>
  286. <dl class="item">
  287. <div id="xmlHeader">
  288. <dt><pre><a href="xmltree.html#xmlHeader"><span class="Identifier">xmlHeader</span></a> <span class="Other">=</span> <span class="StringLit">&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot; ?&gt;\n&quot;</span></pre></dt>
  289. <dd>
  290. Header to use for complete XML output.
  291. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L70" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  292. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L70" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  293. </dd>
  294. </div>
  295. </dl>
  296. </div>
  297. <div class="section" id="12">
  298. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  299. <dl class="item">
  300. <div id="$-procs-all">
  301. <div id="$,XmlNode">
  302. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CXmlNode"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  303. <dd>
  304. <p>Converts <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> into its string representation.</p>
  305. <p>No <tt class="docutils literal"><span class="pre">&lt;$xml ...$&gt;</span></tt> declaration is produced, so that the produced XML fragments are composable.</p>
  306. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L830" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  307. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L830" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  308. </dd>
  309. </div>
  310. </div>
  311. <div id="[]-procs-all">
  312. <div id="[],XmlNode,int_2">
  313. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CXmlNode%2Cint_2"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  314. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  315. <dd>
  316. Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> so that it can be modified.
  317. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L540" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  318. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L540" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  319. </dd>
  320. </div>
  321. <div id="[],XmlNode,int">
  322. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CXmlNode%2Cint"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  323. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  324. <dd>
  325. Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.
  326. <p><strong class="examples_text">Example:</strong></p>
  327. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  328. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  329. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  330. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;first /&gt;&quot;</span>
  331. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;second /&gt;&quot;</span></pre>
  332. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L528" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  333. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L528" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  334. </dd>
  335. </div>
  336. </div>
  337. <div id="add-procs-all">
  338. <div id="add,XmlNode,XmlNode">
  339. <dt><pre><span class="Keyword">proc</span> <a href="#add%2CXmlNode%2CXmlNode"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">,</span> <span class="Identifier">son</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  340. <dd>
  341. <p>Adds the child <tt class="docutils literal"><span class="pre"><span class="Identifier">son</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> must be of <tt class="docutils literal"><span class="pre"><span class="Identifier">xnElement</span></span></tt> type</p>
  342. <p>See also:</p>
  343. <ul class="simple"><li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
  344. <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
  345. <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
  346. <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
  347. <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
  348. <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
  349. <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
  350. </ul>
  351. <p><strong class="examples_text">Example:</strong></p>
  352. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  353. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;my text&quot;</span><span class="Punctuation">)</span>
  354. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;sonTag&quot;</span><span class="Punctuation">)</span>
  355. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;my entity&quot;</span><span class="Punctuation">)</span>
  356. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;myTag&gt;my text&lt;sonTag /&gt;&amp;my entity;&lt;/myTag&gt;&quot;</span></pre>
  357. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L307" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  358. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L307" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  359. </dd>
  360. </div>
  361. <div id="add,XmlNode,openArray[XmlNode]">
  362. <dt><pre><span class="Keyword">proc</span> <a href="#add%2CXmlNode%2CopenArray%5BXmlNode%5D"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">sons</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  363. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  364. <dd>
  365. <p>Adds the children <tt class="docutils literal"><span class="pre"><span class="Identifier">sons</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> must be of <tt class="docutils literal"><span class="pre"><span class="Identifier">xnElement</span></span></tt> type</p>
  366. <p>See also:</p>
  367. <ul class="simple"><li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
  368. <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
  369. <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
  370. <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
  371. <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
  372. <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
  373. <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
  374. </ul>
  375. <p><strong class="examples_text">Example:</strong></p>
  376. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  377. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;my text&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;sonTag&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;my entity&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
  378. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;myTag&gt;my text&lt;sonTag /&gt;&amp;my entity;&lt;/myTag&gt;&quot;</span></pre>
  379. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L329" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  380. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L329" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  381. </dd>
  382. </div>
  383. <div id="add,string,XmlNode,int,int">
  384. <dt><pre><span class="Keyword">proc</span> <a href="#add%2Cstring%2CXmlNode%2Cint%2Cint"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">indent</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span> <span class="Identifier">indWidth</span> <span class="Other">=</span> <span class="DecNumber">2</span><span class="Other">;</span>
  385. <span class="Identifier">addNewLines</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  386. <dd>
  387. Adds the textual representation of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> to string <tt class="docutils literal"><span class="pre"><span class="Identifier">result</span></span></tt>.
  388. <p><strong class="examples_text">Example:</strong></p>
  389. <pre class="listing"><span class="Keyword">var</span>
  390. <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;firstTag&quot;</span><span class="Punctuation">)</span>
  391. <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;my text&quot;</span><span class="Punctuation">)</span>
  392. <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;my comment&quot;</span><span class="Punctuation">)</span>
  393. <span class="Identifier">s</span> <span class="Operator">=</span> <span class="StringLit">&quot;&quot;</span>
  394. <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">)</span>
  395. <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">)</span>
  396. <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">b</span><span class="Punctuation">)</span>
  397. <span class="Identifier">assert</span> <span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;!-- my comment --&gt;&lt;firstTag /&gt;my text&quot;</span></pre>
  398. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L815" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  399. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L815" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  400. </dd>
  401. </div>
  402. </div>
  403. <div id="addEscaped-procs-all">
  404. <div id="addEscaped,string,string">
  405. <dt><pre><span class="Keyword">proc</span> <a href="#addEscaped%2Cstring%2Cstring"><span class="Identifier">addEscaped</span></a><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  406. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  407. <dd>
  408. The same as <a class="reference external" href="#escape,string">result.add(escape(s))</a>, but more efficient.
  409. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L700" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  410. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L700" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  411. </dd>
  412. </div>
  413. </div>
  414. <div id="attr-procs-all">
  415. <div id="attr,XmlNode,string">
  416. <dt><pre><span class="Keyword">proc</span> <a href="#attr%2CXmlNode%2Cstring"><span class="Identifier">attr</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  417. <dd>
  418. <p>Finds the first attribute of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> with a name of <tt class="docutils literal"><span class="pre"><span class="Identifier">name</span></span></tt>. Returns &quot;&quot; on failure.</p>
  419. <p>See also:</p>
  420. <ul class="simple"><li><a class="reference external" href="#attrs,XmlNode">attrs proc</a> for XmlAttributes getter</li>
  421. <li><a class="reference external" href="#attrs=,XmlNode,XmlAttributes">attrs= proc</a> for XmlAttributes setter</li>
  422. <li><a class="reference external" href="#attrsLen,XmlNode">attrsLen proc</a> for number of attributes</li>
  423. </ul>
  424. <p><strong class="examples_text">Example:</strong></p>
  425. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">j</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  426. <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  427. <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
  428. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attr</span><span class="Punctuation">(</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;first value&quot;</span>
  429. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attr</span><span class="Punctuation">(</span><span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;second value&quot;</span></pre>
  430. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L669" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  431. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L669" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  432. </dd>
  433. </div>
  434. </div>
  435. <div id="attrs-procs-all">
  436. <div id="attrs,XmlNode">
  437. <dt><pre><span class="Keyword">proc</span> <a href="#attrs%2CXmlNode"><span class="Identifier">attrs</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlAttributes"><span class="Identifier">XmlAttributes</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  438. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  439. <dd>
  440. <p>Gets the attributes belonging to <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  441. <p>Returns <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt> if attributes have not been initialised for this node.</p>
  442. <p>See also:</p>
  443. <ul class="simple"><li><a class="reference external" href="#attrs=,XmlNode,XmlAttributes">attrs= proc</a> for XmlAttributes setter</li>
  444. <li><a class="reference external" href="#attrsLen,XmlNode">attrsLen proc</a> for number of attributes</li>
  445. <li><a class="reference external" href="#attr,XmlNode,string">attr proc</a> for finding an attribute</li>
  446. </ul>
  447. <p><strong class="examples_text">Example:</strong></p>
  448. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">j</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  449. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">==</span> <span class="Keyword">nil</span>
  450. <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  451. <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
  452. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">==</span> <span class="Identifier">att</span></pre>
  453. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L615" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  454. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L615" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  455. </dd>
  456. </div>
  457. </div>
  458. <div id="attrs=-procs-all">
  459. <div id="attrs=,XmlNode,XmlAttributes">
  460. <dt><pre><span class="Keyword">proc</span> <a href="#attrs%3D%2CXmlNode%2CXmlAttributes"><span class="Identifier">attrs=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">attr</span><span class="Other">:</span> <a href="xmltree.html#XmlAttributes"><span class="Identifier">XmlAttributes</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  461. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  462. <dd>
  463. <p>Sets the attributes belonging to <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  464. <p>See also:</p>
  465. <ul class="simple"><li><a class="reference external" href="#attrs,XmlNode">attrs proc</a> for XmlAttributes getter</li>
  466. <li><a class="reference external" href="#attrsLen,XmlNode">attrsLen proc</a> for number of attributes</li>
  467. <li><a class="reference external" href="#attr,XmlNode,string">attr proc</a> for finding an attribute</li>
  468. </ul>
  469. <p><strong class="examples_text">Example:</strong></p>
  470. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">j</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  471. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">==</span> <span class="Keyword">nil</span>
  472. <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  473. <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
  474. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">==</span> <span class="Identifier">att</span></pre>
  475. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L634" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  476. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L634" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  477. </dd>
  478. </div>
  479. </div>
  480. <div id="attrsLen-procs-all">
  481. <div id="attrsLen,XmlNode">
  482. <dt><pre><span class="Keyword">proc</span> <a href="#attrsLen%2CXmlNode"><span class="Identifier">attrsLen</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  483. <dd>
  484. <p>Returns the number of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s attributes.</p>
  485. <p>See also:</p>
  486. <ul class="simple"><li><a class="reference external" href="#attrs,XmlNode">attrs proc</a> for XmlAttributes getter</li>
  487. <li><a class="reference external" href="#attrs=,XmlNode,XmlAttributes">attrs= proc</a> for XmlAttributes setter</li>
  488. <li><a class="reference external" href="#attr,XmlNode,string">attr proc</a> for finding an attribute</li>
  489. </ul>
  490. <p><strong class="examples_text">Example:</strong></p>
  491. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">j</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  492. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrsLen</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  493. <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  494. <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
  495. <span class="Identifier">assert</span> <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrsLen</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
  496. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L651" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  497. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L651" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  498. </dd>
  499. </div>
  500. </div>
  501. <div id="child-procs-all">
  502. <div id="child,XmlNode,string">
  503. <dt><pre><span class="Keyword">proc</span> <a href="#child%2CXmlNode%2Cstring"><span class="Identifier">child</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  504. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  505. <dd>
  506. Finds the first child element of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> with a name of <tt class="docutils literal"><span class="pre"><span class="Identifier">name</span></span></tt>. Returns <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt> on failure.
  507. <p><strong class="examples_text">Example:</strong></p>
  508. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  509. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;firstSon&quot;</span><span class="Punctuation">)</span>
  510. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;secondSon&quot;</span><span class="Punctuation">)</span>
  511. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;thirdSon&quot;</span><span class="Punctuation">)</span>
  512. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Punctuation">(</span><span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">child</span><span class="Punctuation">(</span><span class="StringLit">&quot;secondSon&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;secondSon /&gt;&quot;</span></pre>
  513. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L838" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  514. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L838" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  515. </dd>
  516. </div>
  517. </div>
  518. <div id="clear-procs-all">
  519. <div id="clear,XmlNode">
  520. <dt><pre><span class="Keyword">proc</span> <a href="#clear%2CXmlNode"><span class="Identifier">clear</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  521. <dd>
  522. Recursively clears all children of an XmlNode.
  523. <p><strong class="examples_text">Example:</strong></p>
  524. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">g</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  525. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;some text&quot;</span><span class="Punctuation">)</span>
  526. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;this is comment&quot;</span><span class="Punctuation">)</span>
  527. <span class="Keyword">var</span> <span class="Identifier">h</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;secondTag&quot;</span><span class="Punctuation">)</span>
  528. <span class="Identifier">h</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;some entity&quot;</span><span class="Punctuation">)</span>
  529. <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  530. <span class="Keyword">var</span> <span class="Identifier">k</span> <span class="Operator">=</span> <span class="Identifier">newXmlTree</span><span class="Punctuation">(</span><span class="StringLit">&quot;treeTag&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Identifier">g</span><span class="Punctuation">,</span> <span class="Identifier">h</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">att</span><span class="Punctuation">)</span>
  531. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;treeTag key1=&quot;first value&quot; key2=&quot;second value&quot;&gt;
  532. &lt;myTag&gt;some text&lt;!-- this is comment --&gt;&lt;/myTag&gt;
  533. &lt;secondTag&gt;&amp;some entity;&lt;/secondTag&gt;
  534. &lt;/treeTag&gt;&quot;&quot;&quot;</span>
  535. <span class="Identifier">clear</span><span class="Punctuation">(</span><span class="Identifier">k</span><span class="Punctuation">)</span>
  536. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;treeTag key1=&quot;first value&quot; key2=&quot;second value&quot; /&gt;&quot;&quot;&quot;</span></pre>
  537. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L545" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  538. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L545" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  539. </dd>
  540. </div>
  541. </div>
  542. <div id="clientData-procs-all">
  543. <div id="clientData,XmlNode">
  544. <dt><pre><span class="Keyword">proc</span> <a href="#clientData%2CXmlNode"><span class="Identifier">clientData</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  545. <dd>
  546. <p>Gets the client data of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  547. <p>The client data field is used by the HTML parser and generator.</p>
  548. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L688" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  549. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L688" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  550. </dd>
  551. </div>
  552. </div>
  553. <div id="clientData=-procs-all">
  554. <div id="clientData=,XmlNode,int">
  555. <dt><pre><span class="Keyword">proc</span> <a href="#clientData%3D%2CXmlNode%2Cint"><span class="Identifier">clientData=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  556. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  557. <dd>
  558. <p>Sets the client data of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  559. <p>The client data field is used by the HTML parser and generator.</p>
  560. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L694" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  561. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L694" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  562. </dd>
  563. </div>
  564. </div>
  565. <div id="delete-procs-all">
  566. <div id="delete,XmlNode,Natural">
  567. <dt><pre><span class="Keyword">proc</span> <a href="#delete%2CXmlNode%2CNatural"><span class="Identifier">delete</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  568. <dd>
  569. <p>Deletes the <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  570. <p>See also:</p>
  571. <ul class="simple"><li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
  572. <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
  573. <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
  574. <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
  575. <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
  576. <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
  577. <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
  578. </ul>
  579. <p><strong class="examples_text">Example:</strong></p>
  580. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  581. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  582. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  583. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">delete</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span>
  584. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;myTag&gt;
  585. &lt;first /&gt;
  586. &lt;/myTag&gt;&quot;&quot;&quot;</span></pre>
  587. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L407" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  588. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L407" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  589. </dd>
  590. </div>
  591. <div id="delete,XmlNode,Slice[int]">
  592. <dt><pre><span class="Keyword">proc</span> <a href="#delete%2CXmlNode%2CSlice%5Bint%5D"><span class="Identifier">delete</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  593. <dd>
  594. <p>Deletes the items <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span><span class="Punctuation">[</span><span class="Identifier">slice</span><span class="Punctuation">]</span></span></tt> of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  595. <p>See also:</p>
  596. <ul class="simple"><li><a class="reference external" href="#delete.XmlNode,int">delete proc</a></li>
  597. <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
  598. <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
  599. <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
  600. <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
  601. <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
  602. <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
  603. </ul>
  604. <p><strong class="examples_text">Example:</strong></p>
  605. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  606. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  607. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;third&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  608. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">delete</span><span class="Punctuation">(</span><span class="FloatNumber">0.</span><span class="Operator">.</span><span class="DecNumber">1</span><span class="Punctuation">)</span>
  609. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;myTag&gt;
  610. &lt;first /&gt;
  611. &lt;/myTag&gt;&quot;&quot;&quot;</span></pre>
  612. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L430" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  613. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L430" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  614. </dd>
  615. </div>
  616. </div>
  617. <div id="escape-procs-all">
  618. <div id="escape,string">
  619. <dt><pre><span class="Keyword">proc</span> <a href="#escape%2Cstring"><span class="Identifier">escape</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  620. <dd>
  621. <p>Escapes <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> for inclusion into an XML document.</p>
  622. <p>Escapes these characters:</p>
  623. <table border="1" class="docutils"><tr><th>char</th><th>is converted to</th></tr>
  624. <tr><td><tt class="docutils literal"><span class="pre">&lt;</span></tt></td><td><tt class="docutils literal"><span class="pre">&amp;lt;</span></tt></td></tr>
  625. <tr><td><tt class="docutils literal"><span class="pre">&gt;</span></tt></td><td><tt class="docutils literal"><span class="pre">&amp;gt;</span></tt></td></tr>
  626. <tr><td><tt class="docutils literal"><span class="pre">&amp;</span></tt></td><td><tt class="docutils literal"><span class="pre">&amp;amp;</span></tt></td></tr>
  627. <tr><td><tt class="docutils literal"><span class="pre">&quot;</span></tt></td><td><tt class="docutils literal"><span class="pre">&amp;quot;</span></tt></td></tr>
  628. <tr><td><tt class="docutils literal"><span class="pre">'</span></tt></td><td><tt class="docutils literal"><span class="pre">&amp;apos;</span></tt></td></tr>
  629. </table><p>You can also use <a class="reference external" href="#addEscaped,string,string">addEscaped proc</a>.</p>
  630. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L711" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  631. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L711" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  632. </dd>
  633. </div>
  634. </div>
  635. <div id="findAll-procs-all">
  636. <div id="findAll,XmlNode,string">
  637. <dt><pre><span class="Keyword">proc</span> <a href="#findAll%2CXmlNode%2Cstring"><span class="Identifier">findAll</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">tag</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">caseInsensitive</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">]</span> {.
  638. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  639. <dd>
  640. A shortcut version to assign in let blocks.
  641. <p><strong class="examples_text">Example:</strong></p>
  642. <pre class="listing"><span class="Keyword">var</span>
  643. <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;good&quot;</span><span class="Punctuation">)</span>
  644. <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;bad&quot;</span><span class="Punctuation">)</span>
  645. <span class="Identifier">d</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;BAD&quot;</span><span class="Punctuation">)</span>
  646. <span class="Identifier">e</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;GOOD&quot;</span><span class="Punctuation">)</span>
  647. <span class="Identifier">b</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;b text&quot;</span><span class="Punctuation">)</span>
  648. <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;c text&quot;</span><span class="Punctuation">)</span>
  649. <span class="Identifier">d</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;d text&quot;</span><span class="Punctuation">)</span>
  650. <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;e text&quot;</span><span class="Punctuation">)</span>
  651. <span class="Keyword">let</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">newXmlTree</span><span class="Punctuation">(</span><span class="StringLit">&quot;father&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Identifier">b</span><span class="Punctuation">,</span> <span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">d</span><span class="Punctuation">,</span> <span class="Identifier">e</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
  652. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;good&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;good&gt;b text&lt;/good&gt;]&quot;</span>
  653. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;BAD&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;BAD&gt;d text&lt;/BAD&gt;]&quot;</span>
  654. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;good&quot;</span><span class="Punctuation">,</span> <span class="Identifier">caseInsensitive</span> <span class="Operator">=</span> <span class="Identifier">true</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;good&gt;b text&lt;/good&gt;, &lt;GOOD&gt;e text&lt;/GOOD&gt;]&quot;</span>
  655. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;BAD&quot;</span><span class="Punctuation">,</span> <span class="Identifier">caseInsensitive</span> <span class="Operator">=</span> <span class="Identifier">true</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;bad&gt;c text&lt;/bad&gt;, &lt;BAD&gt;d text&lt;/BAD&gt;]&quot;</span></pre>
  656. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L893" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  657. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L893" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  658. </dd>
  659. </div>
  660. <div id="findAll,XmlNode,string,seq[XmlNode]">
  661. <dt><pre><span class="Keyword">proc</span> <a href="#findAll%2CXmlNode%2Cstring%2Cseq%5BXmlNode%5D"><span class="Identifier">findAll</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">tag</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">]</span><span class="Other">;</span>
  662. <span class="Identifier">caseInsensitive</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  663. <dd>
  664. <p>Iterates over all the children of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> returning those matching <tt class="docutils literal"><span class="pre"><span class="Identifier">tag</span></span></tt>.</p>
  665. <p>Found nodes satisfying the condition will be appended to the <tt class="docutils literal"><span class="pre"><span class="Identifier">result</span></span></tt> sequence.</p>
  666. <p><strong class="examples_text">Example:</strong></p>
  667. <pre class="listing"><span class="Keyword">var</span>
  668. <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;good&quot;</span><span class="Punctuation">)</span>
  669. <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;bad&quot;</span><span class="Punctuation">)</span>
  670. <span class="Identifier">d</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;BAD&quot;</span><span class="Punctuation">)</span>
  671. <span class="Identifier">e</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;GOOD&quot;</span><span class="Punctuation">)</span>
  672. <span class="Identifier">b</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;b text&quot;</span><span class="Punctuation">)</span>
  673. <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;c text&quot;</span><span class="Punctuation">)</span>
  674. <span class="Identifier">d</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;d text&quot;</span><span class="Punctuation">)</span>
  675. <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;e text&quot;</span><span class="Punctuation">)</span>
  676. <span class="Keyword">let</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">newXmlTree</span><span class="Punctuation">(</span><span class="StringLit">&quot;father&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Identifier">b</span><span class="Punctuation">,</span> <span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">d</span><span class="Punctuation">,</span> <span class="Identifier">e</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
  677. <span class="Keyword">var</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Identifier">newSeq</span><span class="Punctuation">[</span><span class="Identifier">XmlNode</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
  678. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;good&quot;</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">)</span>
  679. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;good&gt;b text&lt;/good&gt;]&quot;</span>
  680. <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">setLen</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span>
  681. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;good&quot;</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">,</span> <span class="Identifier">caseInsensitive</span> <span class="Operator">=</span> <span class="Identifier">true</span><span class="Punctuation">)</span>
  682. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;good&gt;b text&lt;/good&gt;, &lt;GOOD&gt;e text&lt;/GOOD&gt;]&quot;</span>
  683. <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">setLen</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span>
  684. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;BAD&quot;</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">)</span>
  685. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;BAD&gt;d text&lt;/BAD&gt;]&quot;</span>
  686. <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">setLen</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span>
  687. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">&quot;BAD&quot;</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">,</span> <span class="Identifier">caseInsensitive</span> <span class="Operator">=</span> <span class="Identifier">true</span><span class="Punctuation">)</span>
  688. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">&quot;@[&lt;bad&gt;c text&lt;/bad&gt;, &lt;BAD&gt;d text&lt;/BAD&gt;]&quot;</span></pre>
  689. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L854" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  690. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L854" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  691. </dd>
  692. </div>
  693. </div>
  694. <div id="innerText-procs-all">
  695. <div id="innerText,XmlNode">
  696. <dt><pre><span class="Keyword">proc</span> <a href="#innerText%2CXmlNode"><span class="Identifier">innerText</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  697. <dd>
  698. Gets the inner text of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>:<ul class="simple"><li>If <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">xnText</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">xnEntity</span></span></tt>, returns its content.</li>
  699. <li>If <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">xnElement</span></span></tt>, runs recursively on each child node and concatenates the results.</li>
  700. <li>Otherwise returns an empty string.</li>
  701. </ul>
  702. <p>See also:</p>
  703. <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a></li>
  704. </ul>
  705. <p><strong class="examples_text">Example:</strong></p>
  706. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  707. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;my text&quot;</span><span class="Punctuation">)</span>
  708. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;my comment&quot;</span><span class="Punctuation">)</span>
  709. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;my entity&quot;</span><span class="Punctuation">)</span>
  710. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;myTag&gt;my text&lt;!-- my comment --&gt;&amp;my entity;&lt;/myTag&gt;&quot;</span>
  711. <span class="Identifier">assert</span> <span class="Identifier">innerText</span><span class="Punctuation">(</span><span class="Identifier">f</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;my textmy entity&quot;</span></pre>
  712. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L276" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  713. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L276" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  714. </dd>
  715. </div>
  716. </div>
  717. <div id="insert-procs-all">
  718. <div id="insert,XmlNode,XmlNode,int">
  719. <dt><pre><span class="Keyword">proc</span> <a href="#insert%2CXmlNode%2CXmlNode%2Cint"><span class="Identifier">insert</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">,</span> <span class="Identifier">son</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">index</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  720. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  721. <dd>
  722. <p>Inserts the child <tt class="docutils literal"><span class="pre"><span class="Identifier">son</span></span></tt> to a given position in <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt>.</p>
  723. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> must be of <tt class="docutils literal"><span class="pre"><span class="Identifier">xnElement</span></span></tt> kind.</p>
  724. <p>See also:</p>
  725. <ul class="simple"><li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
  726. <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
  727. <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
  728. <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
  729. <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
  730. <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
  731. <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
  732. </ul>
  733. <p><strong class="examples_text">Example:</strong></p>
  734. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  735. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  736. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  737. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;myTag&gt;
  738. &lt;second /&gt;
  739. &lt;first /&gt;
  740. &lt;/myTag&gt;&quot;&quot;&quot;</span></pre>
  741. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L350" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  742. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L350" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  743. </dd>
  744. </div>
  745. <div id="insert,XmlNode,openArray[XmlNode],int">
  746. <dt><pre><span class="Keyword">proc</span> <a href="#insert%2CXmlNode%2CopenArray%5BXmlNode%5D%2Cint"><span class="Identifier">insert</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">sons</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">index</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
  747. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  748. <dd>
  749. <p>Inserts the children openArray<a class="reference internal" href="#`sons`">`sons`</a> to a given position in <tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt>.</p>
  750. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">father</span></span></tt> must be of <tt class="docutils literal"><span class="pre"><span class="Identifier">xnElement</span></span></tt> kind.</p>
  751. <p>See also:</p>
  752. <ul class="simple"><li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
  753. <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
  754. <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
  755. <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
  756. <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
  757. <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
  758. <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
  759. </ul>
  760. <p><strong class="examples_text">Example:</strong></p>
  761. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  762. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  763. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;third&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  764. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;myTag&gt;
  765. &lt;second /&gt;
  766. &lt;third /&gt;
  767. &lt;first /&gt;
  768. &lt;/myTag&gt;&quot;&quot;&quot;</span></pre>
  769. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L378" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  770. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L378" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  771. </dd>
  772. </div>
  773. </div>
  774. <div id="kind-procs-all">
  775. <div id="kind,XmlNode">
  776. <dt><pre><span class="Keyword">proc</span> <a href="#kind%2CXmlNode"><span class="Identifier">kind</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNodeKind"><span class="Identifier">XmlNodeKind</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  777. <dd>
  778. Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s kind.
  779. <p><strong class="examples_text">Example:</strong></p>
  780. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;firstTag&quot;</span><span class="Punctuation">)</span>
  781. <span class="Identifier">assert</span> <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">xnElement</span>
  782. <span class="Keyword">var</span> <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;my text&quot;</span><span class="Punctuation">)</span>
  783. <span class="Identifier">assert</span> <span class="Identifier">b</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">xnText</span></pre>
  784. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L519" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  785. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L519" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  786. </dd>
  787. </div>
  788. </div>
  789. <div id="len-procs-all">
  790. <div id="len,XmlNode">
  791. <dt><pre><span class="Keyword">proc</span> <a href="#len%2CXmlNode"><span class="Identifier">len</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  792. <dd>
  793. Returns the number of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s children.
  794. <p><strong class="examples_text">Example:</strong></p>
  795. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  796. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  797. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  798. <span class="Identifier">assert</span> <span class="Identifier">len</span><span class="Punctuation">(</span><span class="Identifier">f</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
  799. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L509" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  800. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L509" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  801. </dd>
  802. </div>
  803. </div>
  804. <div id="newCData-procs-all">
  805. <div id="newCData,sinkstring">
  806. <dt><pre><span class="Keyword">proc</span> <a href="#newCData%2Csinkstring"><span class="Identifier">newCData</span></a><span class="Other">(</span><span class="Identifier">cdata</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  807. <dd>
  808. Creates a new <tt class="docutils literal"><span class="pre">XmlNode</span></tt> of kind <tt class="docutils literal"><span class="pre">xnCData</span></tt> with the text <tt class="docutils literal"><span class="pre"><span class="Identifier">cdata</span></span></tt>.
  809. <p><strong class="examples_text">Example:</strong></p>
  810. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">d</span> <span class="Operator">=</span> <span class="Identifier">newCData</span><span class="Punctuation">(</span><span class="StringLit">&quot;my cdata&quot;</span><span class="Punctuation">)</span>
  811. <span class="Identifier">assert</span> <span class="Identifier">d</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">xnCData</span>
  812. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">d</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;![CDATA[my cdata]]&gt;&quot;</span></pre>
  813. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L130" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  814. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L130" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  815. </dd>
  816. </div>
  817. </div>
  818. <div id="newComment-procs-all">
  819. <div id="newComment,sinkstring">
  820. <dt><pre><span class="Keyword">proc</span> <a href="#newComment%2Csinkstring"><span class="Identifier">newComment</span></a><span class="Other">(</span><span class="Identifier">comment</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  821. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  822. <dd>
  823. Creates a new <tt class="docutils literal"><span class="pre">XmlNode</span></tt> of kind <tt class="docutils literal"><span class="pre">xnComment</span></tt> with the text <tt class="docutils literal"><span class="pre"><span class="Identifier">comment</span></span></tt>.
  824. <p><strong class="examples_text">Example:</strong></p>
  825. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;my comment&quot;</span><span class="Punctuation">)</span>
  826. <span class="Identifier">assert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">xnComment</span>
  827. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">c</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;!-- my comment --&gt;&quot;</span></pre>
  828. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L120" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  829. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L120" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  830. </dd>
  831. </div>
  832. </div>
  833. <div id="newElement-procs-all">
  834. <div id="newElement,sinkstring">
  835. <dt><pre><span class="Keyword">proc</span> <a href="#newElement%2Csinkstring"><span class="Identifier">newElement</span></a><span class="Other">(</span><span class="Identifier">tag</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  836. <dd>
  837. <p>Creates a new <tt class="docutils literal"><span class="pre">XmlNode</span></tt> of kind <tt class="docutils literal"><span class="pre">xnElement</span></tt> with the given <tt class="docutils literal"><span class="pre"><span class="Identifier">tag</span></span></tt>.</p>
  838. <p>See also:</p>
  839. <ul class="simple"><li><a class="reference external" href="#newXmlTree,string,openArray[XmlNode],XmlAttributes">newXmlTree proc</a></li>
  840. <li><a class="reference external" href="#&lt;&gt;.m,untyped">&lt;&gt; macro</a></li>
  841. </ul>
  842. <p><strong class="examples_text">Example:</strong></p>
  843. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;firstTag&quot;</span><span class="Punctuation">)</span>
  844. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;childTag&quot;</span><span class="Punctuation">)</span>
  845. <span class="Identifier">assert</span> <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">xnElement</span>
  846. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;firstTag&gt;
  847. &lt;childTag /&gt;
  848. &lt;/firstTag&gt;&quot;&quot;&quot;</span></pre>
  849. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L85" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  850. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L85" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  851. </dd>
  852. </div>
  853. </div>
  854. <div id="newEntity-procs-all">
  855. <div id="newEntity,string">
  856. <dt><pre><span class="Keyword">proc</span> <a href="#newEntity%2Cstring"><span class="Identifier">newEntity</span></a><span class="Other">(</span><span class="Identifier">entity</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  857. <dd>
  858. Creates a new <tt class="docutils literal"><span class="pre">XmlNode</span></tt> of kind <tt class="docutils literal"><span class="pre">xnEntity</span></tt> with the text <tt class="docutils literal"><span class="pre"><span class="Identifier">entity</span></span></tt>.
  859. <p><strong class="examples_text">Example:</strong></p>
  860. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">e</span> <span class="Operator">=</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;my entity&quot;</span><span class="Punctuation">)</span>
  861. <span class="Identifier">assert</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">xnEntity</span>
  862. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">e</span> <span class="Operator">==</span> <span class="StringLit">&quot;&amp;my entity;&quot;</span></pre>
  863. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L140" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  864. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L140" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  865. </dd>
  866. </div>
  867. </div>
  868. <div id="newText-procs-all">
  869. <div id="newText,sinkstring">
  870. <dt><pre><span class="Keyword">proc</span> <a href="#newText%2Csinkstring"><span class="Identifier">newText</span></a><span class="Other">(</span><span class="Identifier">text</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  871. <dd>
  872. Creates a new <tt class="docutils literal"><span class="pre">XmlNode</span></tt> of kind <tt class="docutils literal"><span class="pre">xnText</span></tt> with the text <tt class="docutils literal"><span class="pre"><span class="Identifier">text</span></span></tt>.
  873. <p><strong class="examples_text">Example:</strong></p>
  874. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;my text&quot;</span><span class="Punctuation">)</span>
  875. <span class="Identifier">assert</span> <span class="Identifier">b</span><span class="Operator">.</span><span class="Identifier">kind</span> <span class="Operator">==</span> <span class="Identifier">xnText</span>
  876. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">b</span> <span class="Operator">==</span> <span class="StringLit">&quot;my text&quot;</span></pre>
  877. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L104" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  878. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L104" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  879. </dd>
  880. </div>
  881. </div>
  882. <div id="newVerbatimText-procs-all">
  883. <div id="newVerbatimText,sinkstring">
  884. <dt><pre><span class="Keyword">proc</span> <a href="#newVerbatimText%2Csinkstring"><span class="Identifier">newVerbatimText</span></a><span class="Other">(</span><span class="Identifier">text</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  885. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  886. <dd>
  887. Creates a new <tt class="docutils literal"><span class="pre">XmlNode</span></tt> of kind <tt class="docutils literal"><span class="pre">xnVerbatimText</span></tt> with the text <tt class="docutils literal"><span class="pre"><span class="Identifier">text</span></span></tt>. <strong>Since</strong>: Version 1.3.
  888. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L114" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  889. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L114" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  890. </dd>
  891. </div>
  892. </div>
  893. <div id="newXmlTree-procs-all">
  894. <div id="newXmlTree,sinkstring,openArray[XmlNode],XmlAttributes">
  895. <dt><pre><span class="Keyword">proc</span> <a href="#newXmlTree%2Csinkstring%2CopenArray%5BXmlNode%5D%2CXmlAttributes"><span class="Identifier">newXmlTree</span></a><span class="Other">(</span><span class="Identifier">tag</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">children</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">]</span><span class="Other">;</span>
  896. <span class="Identifier">attributes</span><span class="Other">:</span> <a href="xmltree.html#XmlAttributes"><span class="Identifier">XmlAttributes</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  897. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  898. <dd>
  899. <p>Creates a new XML tree with <tt class="docutils literal"><span class="pre"><span class="Identifier">tag</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">children</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">attributes</span></span></tt>.</p>
  900. <p>See also:</p>
  901. <ul class="simple"><li><a class="reference external" href="#newElement,string">newElement proc</a></li>
  902. <li><a class="reference external" href="#&lt;&gt;.m,untyped">&lt;&gt; macro</a></li>
  903. </ul>
  904. <p><strong class="examples_text">Example:</strong></p>
  905. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">g</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  906. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;some text&quot;</span><span class="Punctuation">)</span>
  907. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;this is comment&quot;</span><span class="Punctuation">)</span>
  908. <span class="Keyword">var</span> <span class="Identifier">h</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;secondTag&quot;</span><span class="Punctuation">)</span>
  909. <span class="Identifier">h</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;some entity&quot;</span><span class="Punctuation">)</span>
  910. <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  911. <span class="Keyword">let</span> <span class="Identifier">k</span> <span class="Operator">=</span> <span class="Identifier">newXmlTree</span><span class="Punctuation">(</span><span class="StringLit">&quot;treeTag&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Identifier">g</span><span class="Punctuation">,</span> <span class="Identifier">h</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">att</span><span class="Punctuation">)</span>
  912. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;treeTag key1=&quot;first value&quot; key2=&quot;second value&quot;&gt;
  913. &lt;myTag&gt;some text&lt;!-- this is comment --&gt;&lt;/myTag&gt;
  914. &lt;secondTag&gt;&amp;some entity;&lt;/secondTag&gt;
  915. &lt;/treeTag&gt;&quot;&quot;&quot;</span></pre>
  916. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L150" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  917. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L150" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  918. </dd>
  919. </div>
  920. </div>
  921. <div id="rawTag-procs-all">
  922. <div id="rawTag,XmlNode">
  923. <dt><pre><span class="Keyword">proc</span> <a href="#rawTag%2CXmlNode"><span class="Identifier">rawTag</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  924. <dd>
  925. <p>Returns the underlying 'tag' string by reference.</p>
  926. <p>This is only used for speed hacks.</p>
  927. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L267" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  928. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L267" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  929. </dd>
  930. </div>
  931. </div>
  932. <div id="rawText-procs-all">
  933. <div id="rawText,XmlNode">
  934. <dt><pre><span class="Keyword">proc</span> <a href="#rawText%2CXmlNode"><span class="Identifier">rawText</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  935. <dd>
  936. <p>Returns the underlying 'text' string by reference.</p>
  937. <p>This is only used for speed hacks.</p>
  938. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L258" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  939. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L258" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  940. </dd>
  941. </div>
  942. </div>
  943. <div id="replace-procs-all">
  944. <div id="replace,XmlNode,Natural,openArray[XmlNode]">
  945. <dt><pre><span class="Keyword">proc</span> <a href="#replace%2CXmlNode%2CNatural%2CopenArray%5BXmlNode%5D"><span class="Identifier">replace</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</span></a><span class="Other">;</span> <span class="Identifier">replacement</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">]</span><span class="Other">)</span> {.
  946. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  947. <dd>
  948. <p>Replaces the <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>'th child of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">replacement</span></span></tt> openArray.</p>
  949. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> must be of <tt class="docutils literal"><span class="pre"><span class="Identifier">xnElement</span></span></tt> kind.</p>
  950. <p>See also:</p>
  951. <ul class="simple"><li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
  952. <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
  953. <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
  954. <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
  955. <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
  956. <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
  957. <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
  958. </ul>
  959. <p><strong class="examples_text">Example:</strong></p>
  960. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  961. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  962. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  963. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">replace</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;third&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;fourth&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
  964. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;myTag&gt;
  965. &lt;third /&gt;
  966. &lt;fourth /&gt;
  967. &lt;first /&gt;
  968. &lt;/myTag&gt;&quot;&quot;&quot;</span></pre>
  969. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L453" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  970. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L453" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  971. </dd>
  972. </div>
  973. <div id="replace,XmlNode,Slice[int],openArray[XmlNode]">
  974. <dt><pre><span class="Keyword">proc</span> <a href="#replace%2CXmlNode%2CSlice%5Bint%5D%2CopenArray%5BXmlNode%5D"><span class="Identifier">replace</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">replacement</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">]</span><span class="Other">)</span> {.
  975. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  976. <dd>
  977. <p>Deletes the items <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span><span class="Punctuation">[</span><span class="Identifier">slice</span><span class="Punctuation">]</span></span></tt> of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  978. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> must be of <tt class="docutils literal"><span class="pre"><span class="Identifier">xnElement</span></span></tt> kind.</p>
  979. <p>See also:</p>
  980. <ul class="simple"><li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
  981. <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
  982. <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
  983. <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
  984. <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
  985. <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
  986. <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
  987. </ul>
  988. <p><strong class="examples_text">Example:</strong></p>
  989. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  990. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;first&quot;</span><span class="Punctuation">)</span>
  991. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;second&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;fifth&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
  992. <span class="Identifier">f</span><span class="Operator">.</span><span class="Identifier">replace</span><span class="Punctuation">(</span><span class="FloatNumber">0.</span><span class="Operator">.</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;third&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;fourth&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
  993. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;myTag&gt;
  994. &lt;third /&gt;
  995. &lt;fourth /&gt;
  996. &lt;first /&gt;
  997. &lt;/myTag&gt;&quot;&quot;&quot;</span></pre>
  998. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L481" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  999. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L481" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1000. </dd>
  1001. </div>
  1002. </div>
  1003. <div id="tag-procs-all">
  1004. <div id="tag,XmlNode">
  1005. <dt><pre><span class="Keyword">proc</span> <a href="#tag%2CXmlNode"><span class="Identifier">tag</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#lent"><span class="Identifier">lent</span></a> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1006. <dd>
  1007. <p>Gets the tag name of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  1008. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> has to be an <tt class="docutils literal"><span class="pre">xnElement</span></tt> node.</p>
  1009. <p>See also:</p>
  1010. <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a> for text getter</li>
  1011. <li><a class="reference external" href="#text=,XmlNode,string">text= proc</a> for text setter</li>
  1012. <li><a class="reference external" href="#tag=,XmlNode,string">tag= proc</a> for tag setter</li>
  1013. <li><a class="reference external" href="#innerText,XmlNode">innerText proc</a></li>
  1014. </ul>
  1015. <p><strong class="examples_text">Example:</strong></p>
  1016. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;firstTag&quot;</span><span class="Punctuation">)</span>
  1017. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;childTag&quot;</span><span class="Punctuation">)</span>
  1018. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;firstTag&gt;
  1019. &lt;childTag /&gt;
  1020. &lt;/firstTag&gt;&quot;&quot;&quot;</span>
  1021. <span class="Identifier">assert</span> <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">tag</span> <span class="Operator">==</span> <span class="StringLit">&quot;firstTag&quot;</span></pre>
  1022. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L214" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1023. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L214" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1024. </dd>
  1025. </div>
  1026. </div>
  1027. <div id="tag=-procs-all">
  1028. <div id="tag=,XmlNode,sinkstring">
  1029. <dt><pre><span class="Keyword">proc</span> <a href="#tag%3D%2CXmlNode%2Csinkstring"><span class="Identifier">tag=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">tag</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1030. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1031. <dd>
  1032. <p>Sets the tag name of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  1033. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> has to be an <tt class="docutils literal"><span class="pre">xnElement</span></tt> node.</p>
  1034. <p>See also:</p>
  1035. <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a> for text getter</li>
  1036. <li><a class="reference external" href="#text=,XmlNode,string">text= proc</a> for text setter</li>
  1037. <li><a class="reference external" href="#tag,XmlNode">tag proc</a> for tag getter</li>
  1038. </ul>
  1039. <p><strong class="examples_text">Example:</strong></p>
  1040. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;firstTag&quot;</span><span class="Punctuation">)</span>
  1041. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;childTag&quot;</span><span class="Punctuation">)</span>
  1042. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;firstTag&gt;
  1043. &lt;childTag /&gt;
  1044. &lt;/firstTag&gt;&quot;&quot;&quot;</span>
  1045. <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">tag</span> <span class="Operator">=</span> <span class="StringLit">&quot;newTag&quot;</span>
  1046. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;newTag&gt;
  1047. &lt;childTag /&gt;
  1048. &lt;/newTag&gt;&quot;&quot;&quot;</span></pre>
  1049. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L235" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1050. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L235" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1051. </dd>
  1052. </div>
  1053. </div>
  1054. <div id="text-procs-all">
  1055. <div id="text,XmlNode">
  1056. <dt><pre><span class="Keyword">proc</span> <a href="#text%2CXmlNode"><span class="Identifier">text</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#lent"><span class="Identifier">lent</span></a> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1057. <dd>
  1058. <p>Gets the associated text with the node <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  1059. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> can be a CDATA, Text, comment, or entity node.</p>
  1060. <p>See also:</p>
  1061. <ul class="simple"><li><a class="reference external" href="#text=,XmlNode,string">text= proc</a> for text setter</li>
  1062. <li><a class="reference external" href="#tag,XmlNode">tag proc</a> for tag getter</li>
  1063. <li><a class="reference external" href="#tag=,XmlNode,string">tag= proc</a> for tag setter</li>
  1064. <li><a class="reference external" href="#innerText,XmlNode">innerText proc</a></li>
  1065. </ul>
  1066. <p><strong class="examples_text">Example:</strong></p>
  1067. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;my comment&quot;</span><span class="Punctuation">)</span>
  1068. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">c</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;!-- my comment --&gt;&quot;</span>
  1069. <span class="Identifier">assert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">text</span> <span class="Operator">==</span> <span class="StringLit">&quot;my comment&quot;</span></pre>
  1070. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L178" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1071. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L178" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1072. </dd>
  1073. </div>
  1074. </div>
  1075. <div id="text=-procs-all">
  1076. <div id="text=,XmlNode,sinkstring">
  1077. <dt><pre><span class="Keyword">proc</span> <a href="#text%3D%2CXmlNode%2Csinkstring"><span class="Identifier">text=</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">;</span> <span class="Identifier">text</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1078. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1079. <dd>
  1080. <p>Sets the associated text with the node <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
  1081. <p><tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> can be a CDATA, Text, comment, or entity node.</p>
  1082. <p>See also:</p>
  1083. <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a> for text getter</li>
  1084. <li><a class="reference external" href="#tag,XmlNode">tag proc</a> for tag getter</li>
  1085. <li><a class="reference external" href="#tag=,XmlNode,string">tag= proc</a> for tag setter</li>
  1086. </ul>
  1087. <p><strong class="examples_text">Example:</strong></p>
  1088. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">e</span> <span class="Operator">=</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;my entity&quot;</span><span class="Punctuation">)</span>
  1089. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">e</span> <span class="Operator">==</span> <span class="StringLit">&quot;&amp;my entity;&quot;</span>
  1090. <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">text</span> <span class="Operator">=</span> <span class="StringLit">&quot;a new entity text&quot;</span>
  1091. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">e</span> <span class="Operator">==</span> <span class="StringLit">&quot;&amp;a new entity text;&quot;</span></pre>
  1092. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L196" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1093. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L196" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1094. </dd>
  1095. </div>
  1096. </div>
  1097. <div id="toXmlAttributes-procs-all">
  1098. <div id="toXmlAttributes,varargs[tuple[string,string]]">
  1099. <dt><pre><span class="Keyword">proc</span> <a href="#toXmlAttributes%2Cvarargs%5Btuple%5Bstring%2Cstring%5D%5D"><span class="Identifier">toXmlAttributes</span></a><span class="Other">(</span><span class="Identifier">keyValuePairs</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">key</span><span class="Other">,</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlAttributes"><span class="Identifier">XmlAttributes</span></a> {.
  1100. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1101. <dd>
  1102. Converts <tt class="docutils literal"><span class="pre"><span class="Punctuation">{</span><span class="Identifier">key</span><span class="Punctuation">:</span> <span class="Identifier">value</span><span class="Punctuation">}</span></span></tt> pairs into <tt class="docutils literal"><span class="pre"><span class="Identifier">XmlAttributes</span></span></tt>.
  1103. <p><strong class="examples_text">Example:</strong></p>
  1104. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;first value&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;second value&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
  1105. <span class="Keyword">var</span> <span class="Identifier">j</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  1106. <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
  1107. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">j</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;&lt;myTag key1=&quot;first value&quot; key2=&quot;second value&quot; /&gt;&quot;&quot;&quot;</span></pre>
  1108. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L602" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1109. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L602" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1110. </dd>
  1111. </div>
  1112. </div>
  1113. </dl>
  1114. </div>
  1115. <div class="section" id="15">
  1116. <h1><a class="toc-backref" href="#15">Iterators</a></h1>
  1117. <dl class="item">
  1118. <div id="items-iterators-all">
  1119. <div id="items.i,XmlNode">
  1120. <dt><pre><span class="Keyword">iterator</span> <a href="#items.i%2CXmlNode"><span class="Identifier">items</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1121. <dd>
  1122. Iterates over all direct children of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.
  1123. <p><strong class="examples_text">Example:</strong></p>
  1124. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">g</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;myTag&quot;</span><span class="Punctuation">)</span>
  1125. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;some text&quot;</span><span class="Punctuation">)</span>
  1126. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">&quot;this is comment&quot;</span><span class="Punctuation">)</span>
  1127. <span class="Keyword">var</span> <span class="Identifier">h</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">&quot;secondTag&quot;</span><span class="Punctuation">)</span>
  1128. <span class="Identifier">h</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">&quot;some entity&quot;</span><span class="Punctuation">)</span>
  1129. <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">h</span>
  1130. <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">g</span> <span class="Operator">==</span> <span class="StringLit">&quot;&lt;myTag&gt;some text&lt;!-- this is comment --&gt;&lt;secondTag&gt;&amp;some entity;&lt;/secondTag&gt;&lt;/myTag&gt;&quot;</span>
  1131. <span class="Comment"># for x in g: # the same as `for x in items(g):`</span>
  1132. <span class="Comment"># echo x</span>
  1133. <span class="Comment"># some text</span>
  1134. <span class="Comment"># &lt;!-- this is comment --&gt;</span>
  1135. <span class="Comment"># &lt;secondTag&gt;&amp;some entity;&lt;![CDATA[some cdata]]&gt;&lt;/secondTag&gt;</span></pre>
  1136. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L573" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1137. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L573" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1138. </dd>
  1139. </div>
  1140. </div>
  1141. <div id="mitems-iterators-all">
  1142. <div id="mitems.i,XmlNode">
  1143. <dt><pre><span class="Keyword">iterator</span> <a href="#mitems.i%2CXmlNode"><span class="Identifier">mitems</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="xmltree.html#XmlNode"><span class="Identifier">XmlNode</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1144. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1145. <dd>
  1146. Iterates over all direct children of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> so that they can be modified.
  1147. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L597" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1148. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L597" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1149. </dd>
  1150. </div>
  1151. </div>
  1152. </dl>
  1153. </div>
  1154. <div class="section" id="17">
  1155. <h1><a class="toc-backref" href="#17">Macros</a></h1>
  1156. <dl class="item">
  1157. <div id="&lt;&gt;-macros-all">
  1158. <div id="<>.m,untyped">
  1159. <dt><pre><span class="Keyword">macro</span> <a href="#%3C%3E.m%2Cuntyped"><span class="Identifier">`&lt;&gt;`</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
  1160. <dd>
  1161. <p>Constructor macro for XML. Example usage:</p>
  1162. <p><pre class="listing"><span class="Operator">&lt;&gt;</span><span class="Identifier">a</span><span class="Punctuation">(</span><span class="Identifier">href</span><span class="Operator">=</span><span class="StringLit">&quot;https://nim-lang.org&quot;</span><span class="Punctuation">,</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim rules.&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
  1163. <p>Produces an XML tree for:</p>
  1164. <pre>&lt;a href=&quot;https://nim-lang.org&quot;&gt;Nim rules.&lt;/a&gt;</pre>
  1165. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L938" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1166. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L938" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1167. </dd>
  1168. </div>
  1169. </div>
  1170. </dl>
  1171. </div>
  1172. </div>
  1173. </div>
  1174. <div class="twelve-columns footer">
  1175. <span class="nim-sprite"></span>
  1176. <br>
  1177. <small style="color: var(--hint);">Made with Nim. Generated: 2025-01-09 12:00:17 UTC</small>
  1178. </div>
  1179. </div>
  1180. </div>
  1181. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  1182. </body>
  1183. </html>