std/xmlparser

Source   Edit  

This module parses an XML document and creates its XML tree representation.

Types

XmlError = object of ValueError
  errors*: seq[string]       ## All detected parsing errors.
Exception that is raised for invalid XML. Source   Edit  

Consts

xmlMaxDepth {.intdefine.} = 256
The maximum nesting depth of elements, like libxml2. Deeper documents are rejected, as they could exhaust the stack. This can be set on the command line via -d:xmlMaxDepth=N. Source   Edit  

Procs

proc loadXml(path: string; errors: var seq[string];
             options: set[XmlParseOption] = {reportComments}): XmlNode {.
    ...raises: [IOError, OSError, ValueError, Exception],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Loads and parses XML from file specified by path, and returns a XmlNode. Every occurred parsing error is added to the errors sequence. Source   Edit  
proc loadXml(path: string; options: set[XmlParseOption] = {reportComments}): XmlNode {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Loads and parses XML from file specified by path, and returns a XmlNode. All parsing errors are turned into an XmlError exception. Source   Edit  
proc parseXml(s: Stream; filename: string; errors: var seq[string];
              options: set[XmlParseOption] = {reportComments}): XmlNode {.
    ...raises: [IOError, OSError, IOError, OSError, ValueError, Exception],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Parses the XML from stream s and returns a XmlNode. Every occurred parsing error is added to the errors sequence. If elements are nested deeper than xmlMaxDepth, parsing stops with an error and nil is returned. Source   Edit  
proc parseXml(s: Stream; options: set[XmlParseOption] = {reportComments}): XmlNode {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Parses the XML from stream s and returns a XmlNode. All parsing errors are turned into an XmlError exception. Source   Edit  
proc parseXml(str: string; options: set[XmlParseOption] = {reportComments}): XmlNode {.
    ...raises: [IOError, OSError, ValueError, Exception, XmlError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Parses the XML from string str and returns a XmlNode. All parsing errors are turned into an XmlError exception. Source   Edit