function parseXML(xml) {
if (window.ActiveXObject && window.GetObject) {
var dom = new ActiveXObject('Microsoft.XMLDOM');
dom.loadXML(xml);
return dom;
}
if (window.DOMParser)
return new DOMParser().parseFromString(xml, 'text/xml');
throw new Error('No XML parser available');
}
$(document).ready(function () {
var dom = parseXML('<Criterias><Criteria ProductTypeIDs="1,2">0</Criteria></Criterias>');
$(dom).find('Criteria').each(function () {
var ptids = $(this).attr("ProductTypeIDs");
var innerText = $(this).text();
$(this).text('1');
$(this).attr("ProductTypeIDs", "1,4");
});
$(dom).find('Criteria').each(function () {
var ptids = $(this).attr("ProductTypeIDs");
var innerText = $(this).text();
});
});
Thursday, July 15, 2010
Jquery and XML
http://api.jquery.com/category/attributes/
Subscribe to:
Posts (Atom)