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 this.nativeNode = nativeNode;
22 this._$ = $(nativeNode);
25 $.extend(ElementNode.prototype, {
26 getTagName: function() {
27 return this.nativeNode.tagName.toLowerCase();
30 append: function(documentNode) {
31 this._$.append(documentNode.nativeNode);
34 contents: function() {
36 this._$.contents().each(function() {
37 if(this.nodeType === Node.ELEMENT_NODE)
38 toret.push(new ElementNode(this));
44 sameNode: function(otherNode) {
45 return this.nativeNode === otherNode.nativeNode;
51 documentFromXML: function(xml) {
52 return new Document(parseXML(xml));
55 elementNodeFromXML: function(xml) {
56 return new ElementNode(parseXML(xml));