Hi all and thanks in advance for any help you can provide. Like most people I've copied some code from the internet and modified it to suit my needs. I am passing xml data to a form for editing and then using a function to update it.
The xml file is as follows.
<dataroot>
<Stats id="1">
<Description>We ight</Description>
<Answer>66.6 kgs</Answer>
<OnTarget>Yes </OnTarget>
</Stats>
<Stats id="2">
<Description>He ight</Description>
<Answer>1.85m </Answer>
<OnTarget>Yes </OnTarget>
</Stats>
</dataroot>
I pass the xml file to xsl for formatting and that works fine. I've created a asp form to store the xml content for editing and that works fine as well. The problem is when I try to update the content using the submit link i get an error saying object required. Here is the code.
Dim objDom
Dim objRoot
Dim objStats
Dim objField
Dim strNewHLink
strNewHLink = Request.Form("H Link")
set objXML = Server.CreateOb ject("Microsoft .XMLDOM")
objXML.async = false
objXML.load strXMLFile
Set objRoot = objXML.document Element
Set objStats = objRoot.SelectS ingleNode("Stat s[@id='" & strHLink & "']")
For each objItem in Request.Form
set objField = objStats.Select SingleNode("Sta ts[@id='" & objItem & "']")
objField.Text = Request.Form(ob jItem)
Next
objXML.save strXMLFile
viewDetail strXMLFile, strXSLFile, strNewHLink
I'm new to asp/xml and xPath so I'm not sure what the problem is. When I view the source code I can see that the id is being passed and when I use response.write( objItem) or response.write (Request.Form(o bjItem) in the for loop I see that correct information is there, but I don't know what I am getting wrong.
Again any help would be fantastic. NB: Have searched the web for examples but could not make sense of them. Cheers in advance.
The xml file is as follows.
<dataroot>
<Stats id="1">
<Description>We ight</Description>
<Answer>66.6 kgs</Answer>
<OnTarget>Yes </OnTarget>
</Stats>
<Stats id="2">
<Description>He ight</Description>
<Answer>1.85m </Answer>
<OnTarget>Yes </OnTarget>
</Stats>
</dataroot>
I pass the xml file to xsl for formatting and that works fine. I've created a asp form to store the xml content for editing and that works fine as well. The problem is when I try to update the content using the submit link i get an error saying object required. Here is the code.
Dim objDom
Dim objRoot
Dim objStats
Dim objField
Dim strNewHLink
strNewHLink = Request.Form("H Link")
set objXML = Server.CreateOb ject("Microsoft .XMLDOM")
objXML.async = false
objXML.load strXMLFile
Set objRoot = objXML.document Element
Set objStats = objRoot.SelectS ingleNode("Stat s[@id='" & strHLink & "']")
For each objItem in Request.Form
set objField = objStats.Select SingleNode("Sta ts[@id='" & objItem & "']")
objField.Text = Request.Form(ob jItem)
Next
objXML.save strXMLFile
viewDetail strXMLFile, strXSLFile, strNewHLink
I'm new to asp/xml and xPath so I'm not sure what the problem is. When I view the source code I can see that the id is being passed and when I use response.write( objItem) or response.write (Request.Form(o bjItem) in the for loop I see that correct information is there, but I don't know what I am getting wrong.
Again any help would be fantastic. NB: Have searched the web for examples but could not make sense of them. Cheers in advance.
Comment