12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418 |
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- This file is generated by Nim. -->
- <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>std/xmltree</title>
- <!-- Google fonts -->
- <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
- <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
- <!-- Favicon -->
- <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=="/>
- <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=">
- <!-- CSS -->
- <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
- <!-- JS -->
- <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
- </head>
- <body>
- <div class="document" id="documentId">
- <div class="container">
- <h1 class="title">std/xmltree</h1>
- <div class="row">
- <div class="three columns">
- <div class="theme-select-wrapper">
- <label for="theme-select">Theme: </label>
- <select id="theme-select" onchange="setTheme(this.value)">
- <option value="auto">🌗 Match OS</option>
- <option value="dark">🌑 Dark</option>
- <option value="light">🌕 Light</option>
- </select>
- </div>
- <div id="global-links">
- <ul class="simple-boot">
- <li><a href="manual.html">Manual</a></li>
- <li><a href="lib.html">Standard library</a></li>
- <li> <a id="indexLink" href="theindex.html">Index</a></li>
- <li><a href="compiler/theindex.html">Compiler docs</a></li>
- <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
- <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
- </ul>
- </div>
- <div id="searchInputDiv">
- Search: <input type="search" id="searchInput"
- oninput="search()" />
- </div>
-
- <ul class="simple simple-toc" id="toc-list">
- <li>
- <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#XmlAttributes" title="XmlAttributes = StringTableRef">XmlAttributes</a></li>
- <li><a class="reference" href="#XmlNode" title="XmlNode = ref XmlNodeObj">XmlNode</a></li>
- <li><a class="reference" href="#XmlNodeKind" title="XmlNodeKind = enum
- xnText, ## a text element
- xnVerbatimText, xnElement, ## an element with 0 or more children
- xnCData, ## a CDATA node
- xnEntity, ## an entity (like ``&thing;``)
- xnComment ## an XML comment">XmlNodeKind</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#xmlHeader" title="xmlHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"">xmlHeader</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">$
- <li><a class="reference" href="#%24%2CXmlNode" title="`$`(n: XmlNode): string">`$`(n: XmlNode): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">[]
- <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>
- <li><a class="reference" href="#%5B%5D%2CXmlNode%2Cint" title="`[]`(n: XmlNode; i: int): XmlNode">`[]`(n: XmlNode; i: int): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">add
- <li><a class="reference" href="#add%2CXmlNode%2CXmlNode" title="add(father, son: XmlNode)">add(father, son: XmlNode)</a></li>
- <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>
- <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>
- </ul>
- <ul class="simple nested-toc-section">addEscaped
- <li><a class="reference" href="#addEscaped%2Cstring%2Cstring" title="addEscaped(result: var string; s: string)">addEscaped(result: var string; s: string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">attr
- <li><a class="reference" href="#attr%2CXmlNode%2Cstring" title="attr(n: XmlNode; name: string): string">attr(n: XmlNode; name: string): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">attrs
- <li><a class="reference" href="#attrs%2CXmlNode" title="attrs(n: XmlNode): XmlAttributes">attrs(n: XmlNode): XmlAttributes</a></li>
- </ul>
- <ul class="simple nested-toc-section">attrs=
- <li><a class="reference" href="#attrs%3D%2CXmlNode%2CXmlAttributes" title="attrs=(n: XmlNode; attr: XmlAttributes)">attrs=(n: XmlNode; attr: XmlAttributes)</a></li>
- </ul>
- <ul class="simple nested-toc-section">attrsLen
- <li><a class="reference" href="#attrsLen%2CXmlNode" title="attrsLen(n: XmlNode): int">attrsLen(n: XmlNode): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">child
- <li><a class="reference" href="#child%2CXmlNode%2Cstring" title="child(n: XmlNode; name: string): XmlNode">child(n: XmlNode; name: string): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">clear
- <li><a class="reference" href="#clear%2CXmlNode" title="clear(n: var XmlNode)">clear(n: var XmlNode)</a></li>
- </ul>
- <ul class="simple nested-toc-section">clientData
- <li><a class="reference" href="#clientData%2CXmlNode" title="clientData(n: XmlNode): int">clientData(n: XmlNode): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">clientData=
- <li><a class="reference" href="#clientData%3D%2CXmlNode%2Cint" title="clientData=(n: XmlNode; data: int)">clientData=(n: XmlNode; data: int)</a></li>
- </ul>
- <ul class="simple nested-toc-section">delete
- <li><a class="reference" href="#delete%2CXmlNode%2CNatural" title="delete(n: XmlNode; i: Natural)">delete(n: XmlNode; i: Natural)</a></li>
- <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>
- </ul>
- <ul class="simple nested-toc-section">escape
- <li><a class="reference" href="#escape%2Cstring" title="escape(s: string): string">escape(s: string): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">findAll
- <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>
- <li><a class="reference" href="#findAll%2CXmlNode%2Cstring%2Cseq%5BXmlNode%5D" title="findAll(n: XmlNode; tag: string; result: var seq[XmlNode];
- caseInsensitive = false)">findAll(n: XmlNode; tag: string; result: var seq[XmlNode];
- caseInsensitive = false)</a></li>
- </ul>
- <ul class="simple nested-toc-section">innerText
- <li><a class="reference" href="#innerText%2CXmlNode" title="innerText(n: XmlNode): string">innerText(n: XmlNode): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">insert
- <li><a class="reference" href="#insert%2CXmlNode%2CXmlNode%2Cint" title="insert(father, son: XmlNode; index: int)">insert(father, son: XmlNode; index: int)</a></li>
- <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>
- </ul>
- <ul class="simple nested-toc-section">kind
- <li><a class="reference" href="#kind%2CXmlNode" title="kind(n: XmlNode): XmlNodeKind">kind(n: XmlNode): XmlNodeKind</a></li>
- </ul>
- <ul class="simple nested-toc-section">len
- <li><a class="reference" href="#len%2CXmlNode" title="len(n: XmlNode): int">len(n: XmlNode): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">newCData
- <li><a class="reference" href="#newCData%2Csinkstring" title="newCData(cdata: sink string): XmlNode">newCData(cdata: sink string): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">newComment
- <li><a class="reference" href="#newComment%2Csinkstring" title="newComment(comment: sink string): XmlNode">newComment(comment: sink string): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">newElement
- <li><a class="reference" href="#newElement%2Csinkstring" title="newElement(tag: sink string): XmlNode">newElement(tag: sink string): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">newEntity
- <li><a class="reference" href="#newEntity%2Cstring" title="newEntity(entity: string): XmlNode">newEntity(entity: string): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">newText
- <li><a class="reference" href="#newText%2Csinkstring" title="newText(text: sink string): XmlNode">newText(text: sink string): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">newVerbatimText
- <li><a class="reference" href="#newVerbatimText%2Csinkstring" title="newVerbatimText(text: sink string): XmlNode">newVerbatimText(text: sink string): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">newXmlTree
- <li><a class="reference" href="#newXmlTree%2Csinkstring%2CopenArray%5BXmlNode%5D%2CXmlAttributes" title="newXmlTree(tag: sink string; children: openArray[XmlNode];
- attributes: XmlAttributes = nil): XmlNode">newXmlTree(tag: sink string; children: openArray[XmlNode];
- attributes: XmlAttributes = nil): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">rawTag
- <li><a class="reference" href="#rawTag%2CXmlNode" title="rawTag(n: XmlNode): string">rawTag(n: XmlNode): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">rawText
- <li><a class="reference" href="#rawText%2CXmlNode" title="rawText(n: XmlNode): string">rawText(n: XmlNode): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">replace
- <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>
- <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>
- </ul>
- <ul class="simple nested-toc-section">tag
- <li><a class="reference" href="#tag%2CXmlNode" title="tag(n: XmlNode): lent string">tag(n: XmlNode): lent string</a></li>
- </ul>
- <ul class="simple nested-toc-section">tag=
- <li><a class="reference" href="#tag%3D%2CXmlNode%2Csinkstring" title="tag=(n: XmlNode; tag: sink string)">tag=(n: XmlNode; tag: sink string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">text
- <li><a class="reference" href="#text%2CXmlNode" title="text(n: XmlNode): lent string">text(n: XmlNode): lent string</a></li>
- </ul>
- <ul class="simple nested-toc-section">text=
- <li><a class="reference" href="#text%3D%2CXmlNode%2Csinkstring" title="text=(n: XmlNode; text: sink string)">text=(n: XmlNode; text: sink string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">toXmlAttributes
- <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>
- </ul>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">items
- <li><a class="reference" href="#items.i%2CXmlNode" title="items(n: XmlNode): XmlNode">items(n: XmlNode): XmlNode</a></li>
- </ul>
- <ul class="simple nested-toc-section">mitems
- <li><a class="reference" href="#mitems.i%2CXmlNode" title="mitems(n: var XmlNode): var XmlNode">mitems(n: var XmlNode): var XmlNode</a></li>
- </ul>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#17" id="67">Macros</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section"><>
- <li><a class="reference" href="#%3C%3E.m%2Cuntyped" title="`<>`(x: untyped): untyped">`<>`(x: untyped): untyped</a></li>
- </ul>
- </ul>
- </details>
- </li>
- </ul>
- </div>
- <div class="nine columns" id="content">
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L1" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <div id="tocRoot"></div>
-
- <p class="module-desc">A simple XML tree generator.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">xmltree</span>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"some text"</span><span class="Punctuation">)</span>
- <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">"this is comment"</span><span class="Punctuation">)</span>
- <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">"secondTag"</span><span class="Punctuation">)</span>
- <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">"some entity"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <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">"treeTag"</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>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">"""<treeTag key1="first value" key2="second value">
- <myTag>some text<!-- this is comment --></myTag>
- <secondTag>&some entity;</secondTag>
- </treeTag>"""</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>
- <li><a class="reference external" href="parsexml.html">parsexml module</a> for low-level XML parsing</li>
- <li><a class="reference external" href="htmlgen.html">htmlgen module</a> for html code generator</li>
- </ul>
- </p>
- <div class="section" id="6">
- <h1><a class="toc-backref" href="#6">Imports</a></h1>
- <dl class="item">
- <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>
- </dl>
- </div>
- <div class="section" id="7">
- <h1><a class="toc-backref" href="#7">Types</a></h1>
- <dl class="item">
- <div id="XmlAttributes">
- <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>
- <dd>
-
- <p>An alias for a string to string mapping.</p>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L54" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L54" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="XmlNode">
- <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>
- <dd>
-
- <p>An XML tree consisting of XML nodes.</p>
- <p>Use <a class="reference external" href="#newXmlTree,string,openArray[XmlNode],XmlAttributes">newXmlTree proc</a> for creating a new tree.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L41" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L41" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="XmlNodeKind">
- <dt><pre><a href="xmltree.html#XmlNodeKind"><span class="Identifier">XmlNodeKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
- <span class="Identifier">xnText</span><span class="Other">,</span> <span class="Comment">## a text element</span>
- <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>
- <span class="Identifier">xnCData</span><span class="Other">,</span> <span class="Comment">## a CDATA node</span>
- <span class="Identifier">xnEntity</span><span class="Other">,</span> <span class="Comment">## an entity (like ``&thing;``)</span>
- <span class="Identifier">xnComment</span> <span class="Comment">## an XML comment</span></pre></dt>
- <dd>
-
- Different kinds of XML nodes.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L46" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L46" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="10">
- <h1><a class="toc-backref" href="#10">Consts</a></h1>
- <dl class="item">
- <div id="xmlHeader">
- <dt><pre><a href="xmltree.html#xmlHeader"><span class="Identifier">xmlHeader</span></a> <span class="Other">=</span> <span class="StringLit">"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"</span></pre></dt>
- <dd>
-
- Header to use for complete XML output.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L70" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L70" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="12">
- <h1><a class="toc-backref" href="#12">Procs</a></h1>
- <dl class="item">
- <div id="$-procs-all">
- <div id="$,XmlNode">
- <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>
- <dd>
-
- <p>Converts <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt> into its string representation.</p>
- <p>No <tt class="docutils literal"><span class="pre"><$xml ...$></span></tt> declaration is produced, so that the produced XML fragments are composable.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L830" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L830" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="[]-procs-all">
- <div id="[],XmlNode,int_2">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- 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.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L540" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L540" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="[],XmlNode,int">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <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">"<first />"</span>
- <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">"<second />"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L528" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L528" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="add-procs-all">
- <div id="add,XmlNode,XmlNode">
- <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>
- <dd>
-
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
- <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
- <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"my text"</span><span class="Punctuation">)</span>
- <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">"sonTag"</span><span class="Punctuation">)</span>
- <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">"my entity"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="StringLit">"<myTag>my text<sonTag />&my entity;</myTag>"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L307" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L307" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="add,XmlNode,openArray[XmlNode]">
- <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>
- <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>
- <dd>
-
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
- <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
- <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"my text"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"sonTag"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newEntity</span><span class="Punctuation">(</span><span class="StringLit">"my entity"</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="StringLit">"<myTag>my text<sonTag />&my entity;</myTag>"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L329" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L329" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="add,string,XmlNode,int,int">
- <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>
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"firstTag"</span><span class="Punctuation">)</span>
- <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">"my text"</span><span class="Punctuation">)</span>
- <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newComment</span><span class="Punctuation">(</span><span class="StringLit">"my comment"</span><span class="Punctuation">)</span>
- <span class="Identifier">s</span> <span class="Operator">=</span> <span class="StringLit">""</span>
- <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>
- <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>
- <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>
- <span class="Identifier">assert</span> <span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">"<!-- my comment --><firstTag />my text"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L815" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L815" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addEscaped-procs-all">
- <div id="addEscaped,string,string">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- The same as <a class="reference external" href="#escape,string">result.add(escape(s))</a>, but more efficient.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L700" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L700" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="attr-procs-all">
- <div id="attr,XmlNode,string">
- <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>
- <dd>
-
- <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 "" on failure.</p>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#attrs,XmlNode">attrs proc</a> for XmlAttributes getter</li>
- <li><a class="reference external" href="#attrs=,XmlNode,XmlAttributes">attrs= proc</a> for XmlAttributes setter</li>
- <li><a class="reference external" href="#attrsLen,XmlNode">attrsLen proc</a> for number of attributes</li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
- <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">"key1"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"first value"</span>
- <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">"key2"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"second value"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L669" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L669" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="attrs-procs-all">
- <div id="attrs,XmlNode">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Gets the attributes belonging to <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#attrs=,XmlNode,XmlAttributes">attrs= proc</a> for XmlAttributes setter</li>
- <li><a class="reference external" href="#attrsLen,XmlNode">attrsLen proc</a> for number of attributes</li>
- <li><a class="reference external" href="#attr,XmlNode,string">attr proc</a> for finding an attribute</li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L615" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L615" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="attrs=-procs-all">
- <div id="attrs=,XmlNode,XmlAttributes">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Sets the attributes belonging to <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#attrs,XmlNode">attrs proc</a> for XmlAttributes getter</li>
- <li><a class="reference external" href="#attrsLen,XmlNode">attrsLen proc</a> for number of attributes</li>
- <li><a class="reference external" href="#attr,XmlNode,string">attr proc</a> for finding an attribute</li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L634" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L634" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="attrsLen-procs-all">
- <div id="attrsLen,XmlNode">
- <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>
- <dd>
-
- <p>Returns the number of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s attributes.</p>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#attrs,XmlNode">attrs proc</a> for XmlAttributes getter</li>
- <li><a class="reference external" href="#attrs=,XmlNode,XmlAttributes">attrs= proc</a> for XmlAttributes setter</li>
- <li><a class="reference external" href="#attr,XmlNode,string">attr proc</a> for finding an attribute</li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L651" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L651" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="child-procs-all">
- <div id="child,XmlNode,string">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- 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.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"firstSon"</span><span class="Punctuation">)</span>
- <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">"secondSon"</span><span class="Punctuation">)</span>
- <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">"thirdSon"</span><span class="Punctuation">)</span>
- <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">"secondSon"</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"<secondSon />"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L838" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L838" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="clear-procs-all">
- <div id="clear,XmlNode">
- <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>
- <dd>
-
- Recursively clears all children of an XmlNode.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"some text"</span><span class="Punctuation">)</span>
- <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">"this is comment"</span><span class="Punctuation">)</span>
- <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">"secondTag"</span><span class="Punctuation">)</span>
- <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">"some entity"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <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">"treeTag"</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>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">"""<treeTag key1="first value" key2="second value">
- <myTag>some text<!-- this is comment --></myTag>
- <secondTag>&some entity;</secondTag>
- </treeTag>"""</span>
- <span class="Identifier">clear</span><span class="Punctuation">(</span><span class="Identifier">k</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">"""<treeTag key1="first value" key2="second value" />"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L545" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L545" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="clientData-procs-all">
- <div id="clientData,XmlNode">
- <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>
- <dd>
-
- <p>Gets the client data of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <p>The client data field is used by the HTML parser and generator.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L688" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L688" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="clientData=-procs-all">
- <div id="clientData=,XmlNode,int">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Sets the client data of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <p>The client data field is used by the HTML parser and generator.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L694" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L694" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="delete-procs-all">
- <div id="delete,XmlNode,Natural">
- <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>
- <dd>
-
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">"""<myTag>
- <first />
- </myTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L407" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L407" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="delete,XmlNode,Slice[int]">
- <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>
- <dd>
-
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#delete.XmlNode,int">delete proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"third"</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">"""<myTag>
- <first />
- </myTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L430" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L430" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="escape-procs-all">
- <div id="escape,string">
- <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>
- <dd>
-
- <p>Escapes <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> for inclusion into an XML document.</p>
- <p>Escapes these characters:</p>
- <table border="1" class="docutils"><tr><th>char</th><th>is converted to</th></tr>
- <tr><td><tt class="docutils literal"><span class="pre"><</span></tt></td><td><tt class="docutils literal"><span class="pre">&lt;</span></tt></td></tr>
- <tr><td><tt class="docutils literal"><span class="pre">></span></tt></td><td><tt class="docutils literal"><span class="pre">&gt;</span></tt></td></tr>
- <tr><td><tt class="docutils literal"><span class="pre">&</span></tt></td><td><tt class="docutils literal"><span class="pre">&amp;</span></tt></td></tr>
- <tr><td><tt class="docutils literal"><span class="pre">"</span></tt></td><td><tt class="docutils literal"><span class="pre">&quot;</span></tt></td></tr>
- <tr><td><tt class="docutils literal"><span class="pre">'</span></tt></td><td><tt class="docutils literal"><span class="pre">&apos;</span></tt></td></tr>
- </table><p>You can also use <a class="reference external" href="#addEscaped,string,string">addEscaped proc</a>.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L711" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L711" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="findAll-procs-all">
- <div id="findAll,XmlNode,string">
- <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> {.
- <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>
- <dd>
-
- A shortcut version to assign in let blocks.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">var</span>
- <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"good"</span><span class="Punctuation">)</span>
- <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"bad"</span><span class="Punctuation">)</span>
- <span class="Identifier">d</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"BAD"</span><span class="Punctuation">)</span>
- <span class="Identifier">e</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"GOOD"</span><span class="Punctuation">)</span>
- <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">"b text"</span><span class="Punctuation">)</span>
- <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">"c text"</span><span class="Punctuation">)</span>
- <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">"d text"</span><span class="Punctuation">)</span>
- <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">"e text"</span><span class="Punctuation">)</span>
- <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">"father"</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>
- <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">"good"</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"@[<good>b text</good>]"</span>
- <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">"BAD"</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"@[<BAD>d text</BAD>]"</span>
- <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">"good"</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">"@[<good>b text</good>, <GOOD>e text</GOOD>]"</span>
- <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">"BAD"</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">"@[<bad>c text</bad>, <BAD>d text</BAD>]"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L893" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L893" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="findAll,XmlNode,string,seq[XmlNode]">
- <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>
- <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>
- <dd>
-
- <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>
- <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>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">var</span>
- <span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"good"</span><span class="Punctuation">)</span>
- <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"bad"</span><span class="Punctuation">)</span>
- <span class="Identifier">d</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"BAD"</span><span class="Punctuation">)</span>
- <span class="Identifier">e</span> <span class="Operator">=</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"GOOD"</span><span class="Punctuation">)</span>
- <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">"b text"</span><span class="Punctuation">)</span>
- <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">"c text"</span><span class="Punctuation">)</span>
- <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">"d text"</span><span class="Punctuation">)</span>
- <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">"e text"</span><span class="Punctuation">)</span>
- <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">"father"</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>
- <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>
- <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">"good"</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">"@[<good>b text</good>]"</span>
- <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>
- <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">"good"</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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">"@[<good>b text</good>, <GOOD>e text</GOOD>]"</span>
- <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>
- <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">"BAD"</span><span class="Punctuation">,</span> <span class="Identifier">s</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">"@[<BAD>d text</BAD>]"</span>
- <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>
- <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">findAll</span><span class="Punctuation">(</span><span class="StringLit">"BAD"</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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">s</span> <span class="Operator">==</span> <span class="StringLit">"@[<bad>c text</bad>, <BAD>d text</BAD>]"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L854" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L854" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="innerText-procs-all">
- <div id="innerText,XmlNode">
- <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>
- <dd>
-
- 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>
- <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>
- <li>Otherwise returns an empty string.</li>
- </ul>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"my text"</span><span class="Punctuation">)</span>
- <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">"my comment"</span><span class="Punctuation">)</span>
- <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">"my entity"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="StringLit">"<myTag>my text<!-- my comment -->&my entity;</myTag>"</span>
- <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">"my textmy entity"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L276" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L276" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="insert-procs-all">
- <div id="insert,XmlNode,XmlNode,int">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <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>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
- <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
- <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">"""<myTag>
- <second />
- <first />
- </myTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L350" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L350" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="insert,XmlNode,openArray[XmlNode],int">
- <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>
- <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>
- <dd>
-
- <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>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
- <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
- <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"third"</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">"""<myTag>
- <second />
- <third />
- <first />
- </myTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L378" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L378" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="kind-procs-all">
- <div id="kind,XmlNode">
- <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>
- <dd>
-
- Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s kind.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"firstTag"</span><span class="Punctuation">)</span>
- <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>
- <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">"my text"</span><span class="Punctuation">)</span>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L519" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L519" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="len-procs-all">
- <div id="len,XmlNode">
- <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>
- <dd>
-
- Returns the number of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>'s children.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L509" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L509" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newCData-procs-all">
- <div id="newCData,sinkstring">
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"my cdata"</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">d</span> <span class="Operator">==</span> <span class="StringLit">"<![CDATA[my cdata]]>"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L130" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L130" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newComment-procs-all">
- <div id="newComment,sinkstring">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"my comment"</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">c</span> <span class="Operator">==</span> <span class="StringLit">"<!-- my comment -->"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L120" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L120" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newElement-procs-all">
- <div id="newElement,sinkstring">
- <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>
- <dd>
-
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#newXmlTree,string,openArray[XmlNode],XmlAttributes">newXmlTree proc</a></li>
- <li><a class="reference external" href="#<>.m,untyped"><> macro</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"firstTag"</span><span class="Punctuation">)</span>
- <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">"childTag"</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">"""<firstTag>
- <childTag />
- </firstTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L85" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L85" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newEntity-procs-all">
- <div id="newEntity,string">
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"my entity"</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">e</span> <span class="Operator">==</span> <span class="StringLit">"&my entity;"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L140" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L140" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newText-procs-all">
- <div id="newText,sinkstring">
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"my text"</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">b</span> <span class="Operator">==</span> <span class="StringLit">"my text"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L104" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L104" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newVerbatimText-procs-all">
- <div id="newVerbatimText,sinkstring">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- 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.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L114" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L114" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newXmlTree-procs-all">
- <div id="newXmlTree,sinkstring,openArray[XmlNode],XmlAttributes">
- <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>
- <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>
- <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>
- <dd>
-
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#newElement,string">newElement proc</a></li>
- <li><a class="reference external" href="#<>.m,untyped"><> macro</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"some text"</span><span class="Punctuation">)</span>
- <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">"this is comment"</span><span class="Punctuation">)</span>
- <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">"secondTag"</span><span class="Punctuation">)</span>
- <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">"some entity"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <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">"treeTag"</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>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">k</span> <span class="Operator">==</span> <span class="LongStringLit">"""<treeTag key1="first value" key2="second value">
- <myTag>some text<!-- this is comment --></myTag>
- <secondTag>&some entity;</secondTag>
- </treeTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L150" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L150" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="rawTag-procs-all">
- <div id="rawTag,XmlNode">
- <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>
- <dd>
-
- <p>Returns the underlying 'tag' string by reference.</p>
- <p>This is only used for speed hacks.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L267" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L267" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="rawText-procs-all">
- <div id="rawText,XmlNode">
- <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>
- <dd>
-
- <p>Returns the underlying 'text' string by reference.</p>
- <p>This is only used for speed hacks.</p>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L258" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L258" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="replace-procs-all">
- <div id="replace,XmlNode,Natural,openArray[XmlNode]">
- <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> {.
- <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>
- <dd>
-
- <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>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#replace.XmlNode,Slice[int],openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
- <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
- <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <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">"third"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"fourth"</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">"""<myTag>
- <third />
- <fourth />
- <first />
- </myTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L453" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L453" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="replace,XmlNode,Slice[int],openArray[XmlNode]">
- <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> {.
- <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>
- <dd>
-
- <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>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#replace.XmlNode,int,openArray[XmlNode]">replace proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,XmlNode">add proc</a></li>
- <li><a class="reference external" href="#add,XmlNode,openArray[XmlNode]">add proc</a></li>
- <li><a class="reference external" href="#delete,XmlNode,Natural">delete proc</a></li>
- <li><a class="reference external" href="#delete.XmlNode,Slice[int]">delete proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,XmlNode,int">insert proc</a></li>
- <li><a class="reference external" href="#insert,XmlNode,openArray[XmlNode],int">insert proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"first"</span><span class="Punctuation">)</span>
- <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">"second"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"fifth"</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span>
- <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">"third"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">newElement</span><span class="Punctuation">(</span><span class="StringLit">"fourth"</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">f</span> <span class="Operator">==</span> <span class="LongStringLit">"""<myTag>
- <third />
- <fourth />
- <first />
- </myTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L481" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L481" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="tag-procs-all">
- <div id="tag,XmlNode">
- <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>
- <dd>
-
- <p>Gets the tag name of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a> for text getter</li>
- <li><a class="reference external" href="#text=,XmlNode,string">text= proc</a> for text setter</li>
- <li><a class="reference external" href="#tag=,XmlNode,string">tag= proc</a> for tag setter</li>
- <li><a class="reference external" href="#innerText,XmlNode">innerText proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"firstTag"</span><span class="Punctuation">)</span>
- <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">"childTag"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">"""<firstTag>
- <childTag />
- </firstTag>"""</span>
- <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">"firstTag"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L214" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L214" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="tag=-procs-all">
- <div id="tag=,XmlNode,sinkstring">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Sets the tag name of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a> for text getter</li>
- <li><a class="reference external" href="#text=,XmlNode,string">text= proc</a> for text setter</li>
- <li><a class="reference external" href="#tag,XmlNode">tag proc</a> for tag getter</li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"firstTag"</span><span class="Punctuation">)</span>
- <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">"childTag"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">"""<firstTag>
- <childTag />
- </firstTag>"""</span>
- <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">tag</span> <span class="Operator">=</span> <span class="StringLit">"newTag"</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">a</span> <span class="Operator">==</span> <span class="LongStringLit">"""<newTag>
- <childTag />
- </newTag>"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L235" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L235" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="text-procs-all">
- <div id="text,XmlNode">
- <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>
- <dd>
-
- <p>Gets the associated text with the node <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#text=,XmlNode,string">text= proc</a> for text setter</li>
- <li><a class="reference external" href="#tag,XmlNode">tag proc</a> for tag getter</li>
- <li><a class="reference external" href="#tag=,XmlNode,string">tag= proc</a> for tag setter</li>
- <li><a class="reference external" href="#innerText,XmlNode">innerText proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"my comment"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">c</span> <span class="Operator">==</span> <span class="StringLit">"<!-- my comment -->"</span>
- <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">"my comment"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L178" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L178" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="text=-procs-all">
- <div id="text=,XmlNode,sinkstring">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <p>Sets the associated text with the node <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.</p>
- <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>
- <p>See also:</p>
- <ul class="simple"><li><a class="reference external" href="#text,XmlNode">text proc</a> for text getter</li>
- <li><a class="reference external" href="#tag,XmlNode">tag proc</a> for tag getter</li>
- <li><a class="reference external" href="#tag=,XmlNode,string">tag= proc</a> for tag setter</li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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">"my entity"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">e</span> <span class="Operator">==</span> <span class="StringLit">"&my entity;"</span>
- <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">text</span> <span class="Operator">=</span> <span class="StringLit">"a new entity text"</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">e</span> <span class="Operator">==</span> <span class="StringLit">"&a new entity text;"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L196" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L196" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="toXmlAttributes-procs-all">
- <div id="toXmlAttributes,varargs[tuple[string,string]]">
- <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> {.
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">att</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="StringLit">"first value"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="StringLit">"second value"</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toXmlAttributes</span>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <span class="Identifier">j</span><span class="Operator">.</span><span class="Identifier">attrs</span> <span class="Operator">=</span> <span class="Identifier">att</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">j</span> <span class="Operator">==</span> <span class="LongStringLit">"""<myTag key1="first value" key2="second value" />"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L602" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L602" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- <div class="section" id="15">
- <h1><a class="toc-backref" href="#15">Iterators</a></h1>
- <dl class="item">
- <div id="items-iterators-all">
- <div id="items.i,XmlNode">
- <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>
- <dd>
-
- Iterates over all direct children of <tt class="docutils literal"><span class="pre"><span class="Identifier">n</span></span></tt>.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"myTag"</span><span class="Punctuation">)</span>
- <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">"some text"</span><span class="Punctuation">)</span>
- <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">"this is comment"</span><span class="Punctuation">)</span>
- <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">"secondTag"</span><span class="Punctuation">)</span>
- <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">"some entity"</span><span class="Punctuation">)</span>
- <span class="Identifier">g</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">h</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">g</span> <span class="Operator">==</span> <span class="StringLit">"<myTag>some text<!-- this is comment --><secondTag>&some entity;</secondTag></myTag>"</span>
- <span class="Comment"># for x in g: # the same as `for x in items(g):`</span>
- <span class="Comment"># echo x</span>
- <span class="Comment"># some text</span>
- <span class="Comment"># <!-- this is comment --></span>
- <span class="Comment"># <secondTag>&some entity;<![CDATA[some cdata]]></secondTag></span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L573" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L573" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="mitems-iterators-all">
- <div id="mitems.i,XmlNode">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- 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.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L597" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L597" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- <div class="section" id="17">
- <h1><a class="toc-backref" href="#17">Macros</a></h1>
- <dl class="item">
- <div id="<>-macros-all">
- <div id="<>.m,untyped">
- <dt><pre><span class="Keyword">macro</span> <a href="#%3C%3E.m%2Cuntyped"><span class="Identifier">`<>`</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>
- <dd>
-
- <p>Constructor macro for XML. Example usage:</p>
- <p><pre class="listing"><span class="Operator"><></span><span class="Identifier">a</span><span class="Punctuation">(</span><span class="Identifier">href</span><span class="Operator">=</span><span class="StringLit">"https://nim-lang.org"</span><span class="Punctuation">,</span> <span class="Identifier">newText</span><span class="Punctuation">(</span><span class="StringLit">"Nim rules."</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
- <p>Produces an XML tree for:</p>
- <pre><a href="https://nim-lang.org">Nim rules.</a></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/xmltree.nim#L938" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/xmltree.nim#L938" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- </div>
- </div>
- <div class="twelve-columns footer">
- <span class="nim-sprite"></span>
- <br>
- <small style="color: var(--hint);">Made with Nim. Generated: 2025-01-09 12:00:17 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|