Jump to content
Sign in to follow this  
trainzebra

Creating a new attribute from within an xsl document

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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...