5 points
In a XML document you can't add style, or script. All the nodes are marked as XML, and don't support these HTML features ( and you can't add <?xml-stylesheets... )XML page:
http://api.erepublik.com/v1/feeds/countriesSo.. to do that you need to add HTML (xhtml) nodes.
var xhtml = "http://www.w3.org/1999/xhtml";
var div = document.createElementNS(xhtml,"div");
div.setAttribute("style","border:1px solid red");
someXMLnode.appendChild(div);
Tada!!... you new node "div" is a html node, and support anything other html nodes support, like links.
login to vote
One thing that might be worth noting about your above snippet is that you don't do
which wouldn't work (just in case anyone was thinking that you should use the NS aware functions for attributes as well as elements).
However, this works for example:
but there's really no need, just use the normal
setAttribute().Also, as far as I know, you can add style and script elements using the same method.
And this also applies to running userscripts in SVG documents too obviously.