8 var parseXML = function(xml) {
12 var Document = function(nativeNode) {
13 var $document = $(nativeNode);
16 Object.defineProperty(this, 'root', {get: function() { return new ElementNode($document[0])}});
20 var ElementNode = function(nativeNode) {
21 var myNode = nativeNode,
22 $myNode = $(nativeNode);
24 this._$myNode = $myNode;
27 this.getTagName = function() {
28 return myNode.tagName.toLowerCase();
31 this.append = function(documentNode) {
32 this._$myNode.append(documentNode._$myNode);
35 this.contents = function() {
37 this._$myNode.contents().each(function() {
38 if(this.nodeType === Node.ELEMENT_NODE)
39 toret.push(new ElementNode(this));
44 this.sameNode = function(otherNode) {
45 return this._myNode === otherNode._myNode;
50 documentFromXML: function(xml) {
51 return new Document(parseXML(xml));
54 elementNodeFromXML: function(xml) {
55 return new ElementNode(parseXML(xml));