diff options
Diffstat (limited to 'lib/xmlreader.js')
| -rw-r--r-- | lib/xmlreader.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/xmlreader.js b/lib/xmlreader.js index 51f24a7..f219d2b 100644 --- a/lib/xmlreader.js +++ b/lib/xmlreader.js @@ -105,6 +105,15 @@ Element.prototype.getElementsByTagName = function(name) { return toElementList(elements); }; +Element.prototype.text = function() { + if (this.children.length === 0) { + return ""; + } else if (this.children.length !== 1 || this.children[0].type !== "text") { + throw new Error("Not implemented"); + } + return this.children[0].value; +}; + var elementListPrototype = { getElementsByTagName: function(name) { return toElementList(_.flatten(this.map(function(element) { |
