plugin/index.js
function parse(xml, processNamespaces, angularSyntax) {
    var doc = new XDocument();
    var errors = [];
    var elementStack = [];
    var currentContainer = function () { return elementStack.length > 0 ? elementStack[elementStack.length - 1] : doc; };
    var xParser = new Xml.XmlParser(function (e) {
        var c = currentContainer();
        if (e.eventType === Xml.ParserEventType.StartElement) {
            var newElement = new XElement(e.elementName);
            newElement.add(e.data);
            var attribs = getOwnProperties(e.attributes);
            if (!TypeUtils.isNullOrUndefined(attribs)) {
                for (var p in attribs) {
                    var a = new XAttribute(p);
                    a.value = attribs[p];
                    newElement.add(a);
                }
            }
            currentContainer().add(newElement);
            elementStack.push(newElement);
        }
        else if (e.eventType === Xml.ParserEventType.Text) {
            var newText = new XText();
            newText.value = e.data;
            currentContainer().add(newText);
        }
        else if (e.eventType === Xml.ParserEventType.CDATA) {
            var newCData = new XCData();
            newCData.value = e.data;
            currentContainer().add(newCData);
        }
        else if (e.eventType === Xml.ParserEventType.Comment) {
            var newComment = new XComment();
            newComment.value = e.data;
            currentContainer().add(newComment);
        }
        else if (e.eventType === Xml.ParserEventType.EndElement) {
            elementStack.pop();
        }
    }, function (error, position) {
        errors.push([error, position]);
    }, processNamespaces, angularSyntax);
    xParser.parse(xml);
    if (errors.length > 0) {
        // collect errors and throw
        var exceptionMsg = 'XML parse error:';
        for (var i = 0; i < errors.length; i++) {
            var err = errors[i][0];
            var pos = errors[i][1];
            exceptionMsg += "\n(" + pos.column + "," + pos.line + "): [" + err.name + "] " + err.message;
        }
        throw exceptionMsg;
    }
    return doc;
}
function parse(xml, processNamespaces, angularSyntax) {
    var doc = new XDocument();
    var errors = [];
    var elementStack = [];
    var currentContainer = function () { return elementStack.length > 0 ? elementStack[elementStack.length - 1] : doc; };
    var xParser = new Xml.XmlParser(function (e) {
        var c = currentContainer();
        if (e.eventType === Xml.ParserEventType.StartElement) {
            var newElement = new XElement(e.elementName);
            newElement.add(e.data);
            var attribs = getOwnProperties(e.attributes);
            if (!TypeUtils.isNullOrUndefined(attribs)) {
                for (var p in attribs) {
                    var a = new XAttribute(p);
                    a.value = attribs[p];
                    newElement.add(a);
                }
            }
            currentContainer().add(newElement);
            elementStack.push(newElement);
        }
        else if (e.eventType === Xml.ParserEventType.Text) {
            var newText = new XText();
            newText.value = e.data;
            currentContainer().add(newText);
        }
        else if (e.eventType === Xml.ParserEventType.CDATA) {
            var newCData = new XCData();
            newCData.value = e.data;
            currentContainer().add(newCData);
        }
        else if (e.eventType === Xml.ParserEventType.Comment) {
            var newComment = new XComment();
            newComment.value = e.data;
            currentContainer().add(newComment);
        }
        else if (e.eventType === Xml.ParserEventType.EndElement) {
            elementStack.pop();
        }
    }, function (error, position) {
        errors.push([error, position]);
    }, processNamespaces, angularSyntax);
    xParser.parse(xml);
    if (errors.length > 0) {
        // collect errors and throw
        var exceptionMsg = 'XML parse error:';
        for (var i = 0; i < errors.length; i++) {
            var err = errors[i][0];
            var pos = errors[i][1];
            exceptionMsg += "\n(" + pos.column + "," + pos.line + "): [" + err.name + "] " + err.message;
        }
        throw exceptionMsg;
    }
    return doc;
}
function parse ( xml , processNamespaces , angularSyntax ) { var doc = new XDocument ( ) ; var errors = [ ] ; var elementStack = [ ] ; var currentContainer = function ( ) { return elementStack . length > 0 ? elementStack [ elementStack . length - 1 ] : doc ; } ; var xParser = new Xml . XmlParser ( function ( e ) { var c = currentContainer ( ) ; if ( e . eventType === Xml . ParserEventType . StartElement ) { var newElement = new XElement ( e . elementName ) ; newElement . add ( e . data ) ; var attribs = getOwnProperties ( e . attributes ) ; if ( ! TypeUtils . isNullOrUndefined ( attribs ) ) { for ( var p in attribs ) { var a = new XAttribute ( p ) ; a . value = attribs [ p ] ; newElement . add ( a ) ; } } currentContainer ( ) . add ( newElement ) ; elementStack . push ( newElement ) ; } else if ( e . eventType === Xml . ParserEventType . Text ) { var newText = new XText ( ) ; newText . value = e . data ; currentContainer ( ) . add ( newText ) ; } else if ( e . eventType === Xml . ParserEventType . CDATA ) { var newCData = new XCData ( ) ; newCData . value = e . data ; currentContainer ( ) . add ( newCData ) ; } else if ( e . eventType === Xml . ParserEventType . Comment ) { var newComment = new XComment ( ) ; newComment . value = e . data ; currentContainer ( ) . add ( newComment ) ; } else if ( e . eventType === Xml . ParserEventType . EndElement ) { elementStack . pop ( ) ; } } , function ( error , position ) { errors . push ( [ error , position ] ) ; } , processNamespaces , angularSyntax ) ; xParser . parse ( xml ) ; if ( errors . length > 0 ) { // collect errors and throw
 var exceptionMsg = 'XML parse error:' ; for ( var i = 0 ; i < errors . length ; i ++ ) { var err = errors [ i ] [ 0 ] ; var pos = errors [ i ] [ 1 ] ; exceptionMsg += "\n(" + pos . column + "," + pos . line + "): [" + err . name + "] " + err . message ; } throw exceptionMsg ; } return doc ; }
Parses an XML string.

@param {String} xml The string to parse.
@param {Boolean} [processNamespaces] Process namespaces or not.
@param {Boolean} [angularSyntax] Handle Angular syntax or not.

@return {XDocument} The new document.

@throws Parse error.
Parses an XML string .