i want to add new attribute in XML using jquery
for e.g: XML:
new XML i want display as:
<data>
<section marked="marked"></section>
</data>
from above i want to add marked="marked" attribute using jquery.
i want to add new attribute in XML using jquery
for e.g: XML:
new XML i want display as:
<data>
<section marked="marked"></section>
</data>
from above i want to add marked="marked" attribute using jquery.
You can add attribute in any XML tag as you add in HTML
First your XML is saved in any variable
var a = '<data><section></section></data>';
Edit
Now you have to add this line too and it will work fine.
a = $(a);
This line will add an attribute in section tag
a.find('section').attr('marked', 'marked');
a = $(a) the variable a is now jQuery Object. To get modified xml you have to do this a[0].outerHTML.