[ deerbeer @ 03.11.2011. 12:21 ] @
Imam neki xml i ucitam ga
Code:
 

  var xmlDoc = jQuery.parseXML(xml);
  var jqXmlDoc =  jQuery(xmlDoc);  
 //setujem vrednosti nekih nodova u xml-u 





Kako da dobijem izmenjeni xml iz jqXmlDoc objekta ?
[ Nikola Poša @ 03.11.2011. 17:45 ] @
Misliš da ponovo dobiješ XML kao string? Onda probaj ovako nešto:
Code:
var xmlStr = xmlDoc.xml ? xmlDoc.xml : (new XMLSerializer()).serializeToString(xmlDoc);

Dakle to radiš direktno nad onim XMLDocument objektom kojeg si dobio preko $.parseXML().
[ deerbeer @ 04.11.2011. 08:41 ] @
Hvala !
Jos jedno pitanje : Da li jquery interno koristi ms-xml parser (i koju veriziju) za ie browsere ?
[ deerbeer @ 11.11.2011. 10:22 ] @
Evo klase za manipulaciju sa xml-om ako nekom zatreba :
jquery1.7 rc2 ;

XmlNode:
Code:
 
function jqXmlNode(domNode) {

    this.jqXmlNode = domNode;

    this.childNodes = new Array();

    for (var i = 0; i < domNode.childNodes.length; i++) {
        var node = domNode.childNodes[i];
        this.childNodes.push(new jqXmlNode(node));
    }
           
    this.attribute = function (name) {
        return this.jqXmlNode.getAttribute(name)
    }

    this.setText = function (value) {
        this.jqXmlNode.textContent = value;  
    }

    this.getText = function () {
        return this.jqXmlNode.textContent; 
    }

    this.name = function () {
        return this.jqXmlNode.nodeName;
    }
}


XmlDocument :
Code:
 

function jqXmlDocument() {

    this.jqXmlDoc = null;

    this.loadXML = function (xmldata) {

        this.jqXmlDoc = jQuery.parseXML(xmldata);

        if (this.jqXmlDoc == null)
            return false;
     
        return true;
    }

    this.documentElement = function () {
        
         var ret = null ;
        jQuery(this.jqXmlDoc).each(function (i) {
            ret = jQuery(this)[0].childNodes[0];
        });
         
        return new jqXmlNode(ret); 
    }

    // query nodes 
    this.selectNode = function (name) {

        var retNode = null; 
        jQuery(this.jqXmlDoc).find(name).each(function (i) {
            retNode = new jqXmlNode(this);
        });

        return retNode ;  
    }

    this.Xml = function (name) {

        var xmlString = this.jqXmlDoc.xml ? this.jqXmlDoc.xml : (new XMLSerializer()).serializeToString(this.jqXmlDoc);
        return xmlString;  
    }

}