Jump to content

Creating a new attribute from within an xsl document


trainzebra

Recommended Posts

Hey all. I'm attempting to add an attribute to an xml node from within an xsl document, using javascript. My code at the moment looks like this.

			var worker = window.location.href.split('/');			var file = worker[worker.length-1].split('?');			document.write(file[0]);						xmlDoc=new ActiveXObject("Microsoft.XMLDOM");			xmlDoc.async=false;			xmlDoc.load(file[0]);						var x = xmlDoc.getElementsByTagName('Header');			var newatt;						for(i=0; i != x.length; i++){				newatt = xmlDoc.createAttribute("state");				newatt.value = str;				x[i].setAttributeNode(newatt);			}						for(i=0; i != x.length; i++){				document.write(x[i].getAttribute("state"));			}

File[0] contains the name of the xml document to be loaded. The line document.write(x.getAttribute("state") at the end outputs the correct string (str), but doesn't seem to be actually updating the xml file. This is a problem, as I need the current state actually in the xml file so that xsl can reference it in an if statement later. Does anyone know how I can do this?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...