Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
08-21-2004, 03:13 PM #1
- Join Date
- Jun 2004
- Thanked 0 Times in 0 Posts
.setAttribute where attribute value is a variable
Hi. I'm using ASP/vbscript to append elements and associated attributes to an xml file. Both the element values and attribute value come from a form. The problem i have is that i can't get the relevant form entry assigned to the attribute value. This is what i have. The relevant parts are in bold.
<% dim xid dim xstatus dim xsurname dim xforename dim xaddress dim xemail dim xhometelno dim xmobiletelno dim xworktelno set xid = Request.Form("id") set xstatus = Request.Form("status") set xsurname = Request.Form("surname") set xforename = Request.Form("forename") set xaddress = Request.Form("address") set xemail = Request.Form("email") set xhometelno = Request.Form("hometelno") set xmobiletelno = Request.Form("mobiletelno") set xworktelno = Request.Form("worktelno") Set objXML = server.CreateObject("Microsoft.XMLDOM") objXML.async = False objXML.load(server.MapPath("phonebooktest.xml")) set objphonebook = objXML.documentElement set objperson = objXML.createElement ("person") objperson.setAttribute "id", xidthe problem is in the line above. the DOM states that the method must be used in the form xxxx.setAttribute "attribute_name" "value of attribute" and the quotes must be included so when i put the variable xid as opposed to an absolute value such as "xid" it simply ignores it.
set objphonebook = objXML.documentElement set objperson = objXML.createElement ("person") set Attr = objXML.createAttribute("id") set Text = objXML.createTextNode(xid) Attr.appendChild(Text) objperson.setAttributeNode(Attr) objphonebook.appendChild objperson