This project is read-only.

The value property of an XELement should decode XEntity value


When you put a value to an XElement that creates XEntity and then read the value property, the characters are lost. For example, new Ltxml.XElement("Test", "<b>").value will be b. It should read back <b>. I was able to make a quick fix but not sure if I missed anything or broke other things without being aware of. Here is my quick fix:

Add a decode method to the XEntity:
        this.decode = function () {
            var div = document.createElement('div');
            div.innerHTML = this.toString();
            return div.firstChild.nodeValue;
Change the Ltxml.XElement.prototype.getValue implementation to call the decode method:
    Ltxml.XElement.prototype.getValue = function () {
        var returnValue = this
            .where(function (n) {
                return n.nodeType === 'Text' ||
                n.nodeType === 'CDATA' ||
                n.nodeType === 'Entity';
            .select(function (n)
                if (n.nodeType === "Entity") {
                    return n.decode();
                } else {
                    return n.value;
        return returnValue;