Jquery parses a simple example of an XML string

  • 2020-03-30 02:35:54
  • OfStack


var $xml = $("<aa><bb para="bbpara">bbtext</bb> <cc> cctext </cc><cc>789798</cc>aatext</aa>");
function log(o){
 $("textarea").val($("textarea").val()+"n"+o);
}
log($xml.text());
log($xml.html());
log($xml.children("cc").html());
log($xml.children("bb").attr("para"));
log("each");
$xml.find("cc").each(function(){
 log($(this).text());
});


Related articles: