This module implements XML DOM Level 2 Core specification (http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html)
Types
EDOMException = object of ValueError
- Base exception object for all DOM Exceptions Source
EDOMStringSizeErr = object of EDOMException
- If the specified range of text does not fit into a DOMString Currently not used(Since DOMString is just string) Source
EHierarchyRequestErr = object of EDOMException
- If any node is inserted somewhere it doesn't belong Source
EIndexSizeErr = object of EDOMException
- If index or size is negative, or greater than the allowed value Source
EInuseAttributeErr = object of EDOMException
- If an attempt is made to add an attribute that is already in use elsewhere Source
EInvalidAccessErr = object of EDOMException
- If a parameter or an operation is not supported by the underlying object. Source
EInvalidCharacterErr = object of EDOMException
- This exception is raised when a string parameter contains an illegal character Source
EInvalidModificationErr = object of EDOMException
- If an attempt is made to modify the type of the underlying object. Source
EInvalidStateErr = object of EDOMException
- If an attempt is made to use an object that is not, or is no longer, usable. Source
ENamespaceErr = object of EDOMException
- If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces. Source
ENotFoundErr = object of EDOMException
- If an attempt is made to reference a node in a context where it does not exist Source
ENotSupportedErr = object of EDOMException
- If the implementation does not support the requested type of object or operation. Source
ENoDataAllowedErr = object of EDOMException
- If data is specified for a node which does not support data Source
ENoModificationAllowedErr = object of EDOMException
- If an attempt is made to modify an object where modifications are not allowed Source
ESyntaxErr = object of EDOMException
- If an invalid or illegal string is specified. Source
EWrongDocumentErr = object of EDOMException
- If a node is used in a different document than the one that created it (that doesn't support it) Source
PDOMImplementation = ref DOMImplementation
- Source
PNode = ref Node
- Source
PElement = ref Element
- Source
PCharacterData = ref CharacterData
- Source
PDocument = ref Document
- Source
PAttr = ref Attr
- Source
PDocumentFragment = ref DocumentFragment
- Source
PText = ref Text
- Source
PComment = ref Comment
- Source
PCDataSection = ref CDataSection
- Source
PProcessingInstruction = ref ProcessingInstruction
- Source
Procs
proc getDOM(): PDOMImplementation {.raises: [], tags: [].}
- Returns a DOMImplementation Source
proc createDocument(dom: PDOMImplementation; namespaceURI: string; qualifiedName: string): PDocument {.raises: [], tags: [].}
- Creates an XML Document object of the specified type with its document element. Source
proc createDocument(dom: PDOMImplementation; n: PElement): PDocument {. raises: [], tags: [].}
- Creates an XML Document object of the specified type with its document element. Source
proc hasFeature(dom: PDOMImplementation; feature: string; version: string = ""): bool {. raises: [], tags: [].}
- Returns true if this version of the DomImplementation implements feature, otherwise false Source
proc implementation(doc: PDocument): PDOMImplementation {.raises: [], tags: [].}
- Source
proc documentElement(doc: PDocument): PElement {.raises: [], tags: [].}
- Source
proc createAttribute(doc: PDocument; name: string): PAttr {. raises: [EInvalidCharacterErr], tags: [].}
- Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method. To create an attribute with a qualified name and namespace URI, use the createAttributeNS method. Source
proc createAttributeNS(doc: PDocument; namespaceURI: string; qualifiedName: string): PAttr {. raises: [EInvalidCharacterErr, ENamespaceErr], tags: [].}
- Creates an attribute of the given qualified name and namespace URI Source
proc createCDATASection(doc: PDocument; data: string): PCDataSection {. raises: [], tags: [].}
- Creates a CDATASection node whose value is the specified string. Source
proc createComment(doc: PDocument; data: string): PComment {.raises: [], tags: [].}
- Creates a Comment node given the specified string. Source
proc createDocumentFragment(doc: PDocument): PDocumentFragment {.raises: [], tags: [].}
- Creates an empty DocumentFragment object. Source
proc createElement(doc: PDocument; tagName: string): PElement {. raises: [EInvalidCharacterErr], tags: [].}
- Creates an element of the type specified. Source
proc createElementNS(doc: PDocument; namespaceURI: string; qualifiedName: string): PElement {. raises: [ENamespaceErr, EInvalidCharacterErr], tags: [].}
- Creates an element of the given qualified name and namespace URI. Source
proc createProcessingInstruction(doc: PDocument; target: string; data: string): PProcessingInstruction {. raises: [EInvalidCharacterErr], tags: [].}
- Creates a ProcessingInstruction node given the specified name and data strings. Source
proc createTextNode(doc: PDocument; data: string): PText {.raises: [], tags: [].}
- Creates a Text node given the specified string. Source
proc getElementsByTagName(doc: PDocument; tagName: string): seq[PNode] {. raises: [], tags: [].}
- Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree. Source
proc getElementsByTagNameNS(doc: PDocument; namespaceURI: string; localName: string): seq[PNode] {.raises: [], tags: [].}
- Returns a NodeList of all the Elements with a given localName and namespaceURI in the order in which they are encountered in a preorder traversal of the Document tree. Source
proc importNode(doc: PDocument; importedNode: PNode; deep: bool): PNode {. raises: [ENotSupportedErr], tags: [].}
- Imports a node from another document to this document Source
proc firstChild(n: PNode): PNode {.raises: [], tags: [].}
- Returns this node's first child Source
proc lastChild(n: PNode): PNode {.raises: [], tags: [].}
- Returns this node's last child Source
proc localName(n: PNode): string {.raises: [], tags: [].}
- Returns this nodes local name Source
proc namespaceURI(n: PNode): string {.raises: [], tags: [].}
- Returns this nodes namespace URI Source
proc namespaceURI=(n: PNode; value: string) {.raises: [], tags: [].}
- Source
proc nextSibling(n: PNode): PNode {.raises: [], tags: [].}
- Returns the next sibling of this node Source
proc nodeName(n: PNode): string {.raises: [], tags: [].}
- Returns the name of this node Source
proc nodeType(n: PNode): int {.raises: [], tags: [].}
- Returns the type of this node Source
proc ownerDocument(n: PNode): PDocument {.raises: [], tags: [].}
- Returns the owner document of this node Source
proc parentNode(n: PNode): PNode {.raises: [], tags: [].}
- Returns the parent node of this node Source
proc previousSibling(n: PNode): PNode {.raises: [], tags: [].}
- Returns the previous sibling of this node Source
proc prefix=(n: PNode; value: string) {.raises: [EInvalidCharacterErr, ENamespaceErr], tags: [].}
- Modifies the prefix of this node Source
proc appendChild(n: PNode; newChild: PNode) {.raises: [EHierarchyRequestErr, EWrongDocumentErr, ENoModificationAllowedErr], tags: [].}
- Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed. Source
proc cloneNode(n: PNode; deep: bool): PNode {.raises: [], tags: [].}
- Returns a duplicate of this node, if deep is true, Element node's children are copied Source
proc hasAttributes(n: PNode): bool {.raises: [], tags: [].}
- Returns whether this node (if it is an element) has any attributes. Source
proc hasChildNodes(n: PNode): bool {.raises: [], tags: [].}
- Returns whether this node has any children. Source
proc insertBefore(n: PNode; newChild: PNode; refChild: PNode): PNode {. raises: [EWrongDocumentErr], tags: [].}
- Inserts the node newChild before the existing child node refChild. If refChild is nil, insert newChild at the end of the list of children. Source
proc isSupported(n: PNode; feature: string; version: string): bool {.raises: [], tags: [].}
- Tests whether the DOM implementation implements a specific feature and that feature is supported by this node. Source
proc normalize(n: PNode) {.raises: [], tags: [].}
- Merges all separated TextNodes together, and removes any empty TextNodes Source
proc removeChild(n: PNode; oldChild: PNode): PNode {.raises: [ENotFoundErr], tags: [].}
- Removes the child node indicated by oldChild from the list of children, and returns it. Source
proc replaceChild(n: PNode; newChild: PNode; oldChild: PNode): PNode {. raises: [EWrongDocumentErr, ENotFoundErr], tags: [].}
- Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node. Source
proc getNamedItem(nList: seq[PNode]; name: string): PNode {.raises: [], tags: [].}
- Retrieves a node specified by name. If this node cannot be found returns nil Source
proc getNamedItem(nList: seq[PAttr]; name: string): PAttr {.raises: [], tags: [].}
- Retrieves a node specified by name. If this node cannot be found returns nil Source
proc getNamedItemNS(nList: seq[PNode]; namespaceURI: string; localName: string): PNode {. raises: [], tags: [].}
- Retrieves a node specified by localName and namespaceURI. If this node cannot be found returns nil Source
proc getNamedItemNS(nList: seq[PAttr]; namespaceURI: string; localName: string): PAttr {. raises: [], tags: [].}
- Retrieves a node specified by localName and namespaceURI. If this node cannot be found returns nil Source
proc item(nList: seq[PNode]; index: int): PNode {.raises: [], tags: [].}
- Returns the index th item in the map. If index is greater than or equal to the number of nodes in this map, this returns nil. Source
proc removeNamedItem(nList: var seq[PNode]; name: string): PNode {. raises: [ENotFoundErr], tags: [].}
- Removes a node specified by name Raises the ENotFoundErr exception, if the node was not found Source
proc removeNamedItemNS(nList: var seq[PNode]; namespaceURI: string; localName: string): PNode {.raises: [ENotFoundErr], tags: [].}
- Removes a node specified by local name and namespace URI Source
proc setNamedItem(nList: var seq[PNode]; arg: PNode): PNode {. raises: [EWrongDocumentErr], tags: [].}
- Adds arg as a Node to the NList If a node with the same name is already present in this map, it is replaced by the new one. Source
proc setNamedItem(nList: var seq[PAttr]; arg: PAttr): PAttr {. raises: [EWrongDocumentErr, EInuseAttributeErr], tags: [].}
- Adds arg as a Node to the NList If a node with the same name is already present in this map, it is replaced by the new one. Source
proc setNamedItemNS(nList: var seq[PNode]; arg: PNode): PNode {. raises: [EWrongDocumentErr], tags: [].}
- Adds a node using its namespaceURI and localName Source
proc setNamedItemNS(nList: var seq[PAttr]; arg: PAttr): PAttr {. raises: [EWrongDocumentErr, EInuseAttributeErr], tags: [].}
- Adds a node using its namespaceURI and localName Source
proc name(a: PAttr): string {.raises: [], tags: [].}
- Returns the name of the Attribute Source
proc specified(a: PAttr): bool {.raises: [], tags: [].}
- Specifies whether this attribute was specified in the original document Source
proc ownerElement(a: PAttr): PElement {.raises: [], tags: [].}
- Returns this Attributes owner element Source
proc tagName(el: PElement): string {.raises: [], tags: [].}
- Returns the Element Tag Name Source
proc getAttribute(el: PElement; name: string): string {.raises: [], tags: [].}
- Retrieves an attribute value by name Source
proc getAttributeNS(el: PElement; namespaceURI: string; localName: string): string {. raises: [], tags: [].}
- Retrieves an attribute value by localName and namespaceURI Source
proc getAttributeNode(el: PElement; name: string): PAttr {.raises: [], tags: [].}
- Retrieves an attribute node by name To retrieve an attribute node by qualified name and namespace URI, use the getAttributeNodeNS method Source
proc getAttributeNodeNS(el: PElement; namespaceURI: string; localName: string): PAttr {. raises: [], tags: [].}
- Retrieves an Attr node by localName and namespaceURI Source
proc getElementsByTagName(el: PElement; name: string): seq[PNode] {.raises: [], tags: [].}
- Returns a NodeList of all descendant Elements of el with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree If name is *, returns all descendant of el Source
proc getElementsByTagNameNS(el: PElement; namespaceURI: string; localName: string): seq[PNode] {.raises: [], tags: [].}
- Returns a NodeList of all the descendant Elements with a given localName and namespaceURI in the order in which they are encountered in a preorder traversal of this Element tree Source
proc hasAttribute(el: PElement; name: string): bool {.raises: [], tags: [].}
- Returns true when an attribute with a given name is specified on this element , false otherwise. Source
proc hasAttributeNS(el: PElement; namespaceURI: string; localName: string): bool {. raises: [], tags: [].}
- Returns true when an attribute with a given localName and namespaceURI is specified on this element , false otherwise Source
proc removeAttribute(el: PElement; name: string) {.raises: [], tags: [].}
- Removes an attribute by name Source
proc removeAttributeNS(el: PElement; namespaceURI: string; localName: string) {. raises: [], tags: [].}
- Removes an attribute by localName and namespaceURI Source
proc removeAttributeNode(el: PElement; oldAttr: PAttr): PAttr {. raises: [ENotFoundErr], tags: [].}
- Removes the specified attribute node If the attribute node cannot be found raises ENotFoundErr Source
proc setAttributeNode(el: PElement; newAttr: PAttr): PAttr {. raises: [EWrongDocumentErr, EInuseAttributeErr], tags: [].}
- Adds a new attribute node, if an attribute with the same nodeName is present, it is replaced by the new one and the replaced attribute is returned, otherwise nil is returned. Source
proc setAttributeNodeNS(el: PElement; newAttr: PAttr): PAttr {. raises: [EWrongDocumentErr, EInuseAttributeErr], tags: [].}
- Adds a new attribute node, if an attribute with the localName and namespaceURI of newAttr is present, it is replaced by the new one and the replaced attribute is returned, otherwise nil is returned. Source
proc setAttribute(el: PElement; name: string; value: string) {. raises: [EInvalidCharacterErr, EWrongDocumentErr, EInuseAttributeErr], tags: [].}
- Adds a new attribute, as specified by name and value If an attribute with that name is already present in the element, its value is changed to be that of the value parameter Raises the EInvalidCharacterErr if the specified name contains illegal characters Source
proc setAttributeNS(el: PElement; namespaceURI, localName, value: string) {.raises: [ EInvalidCharacterErr, ENamespaceErr, EWrongDocumentErr, EInuseAttributeErr], tags: [].}
- Adds a new attribute, as specified by namespaceURI, localName and value. Source
proc splitData(textNode: PText; offset: int): PText {.raises: [EIndexSizeErr], tags: [].}
- Breaks this node into two nodes at the specified offset, keeping both in the tree as siblings. Source
proc target(pi: PProcessingInstruction): string {.raises: [], tags: [].}
- Returns the Processing Instructions target Source
proc `$`(doc: PDocument): string {.raises: [], tags: [].}
- Converts a PDocument object into a string representation of it's XML Source