By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,967 Members | 1,710 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,967 IT Pros & Developers. It's quick & easy.

Xml in

P: 63
Hi guys
I'm new to this group Hi to all,let me go straight to my doubt--->

I've just started working with XML.I want to update an XML file(in the file itself it has no connection with database) . I tried out this example in

this page.There is an xsl and xml file and have added code to update it but when I click Submit button to edit I get this error

__________________________________________________ ________________

The HTTP verb POST used to access path '/DisplayXml/EditContact.asp' is not allowed.
__________________________________________________ ________________

Can someone just tell me what causes this error?

My code is as follows

__________________________________________________ ________________
__________________________________________________ ________________

Partial Class EditContactXmlFile
Inherits System.Web.UI.Page

Private strXMLFile As String = "./Employee.xml"
Private strXSLFile As String = "./Employee.xsl"

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

'Test to see if the form has been submitted. If it has,
'update the XML file. If not, transform the XML file for
If Request.Form("btnSubmit") = "" Then
loadXMLFile(Server.MapPath("Contact.xml"), _
End If

End Sub

'The "loadXMLFile" Function accepts two parameters.
'strXMLFile - The path and file name of the XML file.
'strXSLFilee - The path and file name of the XSL file.
Function loadXMLFile(ByVal strXMLFile, ByVal strXSLFile)

'Declare local variables
Dim objXML
Dim objXSL

'Instantiate the XMLDOM Object that will hold the XML file.
objXML = Server.CreateObject("Microsoft.XMLDOM")

'Turn off asyncronous file loading.
objXML.async = False

'Load the XML file.

'Instantiate the XMLDOM Object that will hold the XSL file.
objXSL = Server.CreateObject("Microsoft.XMLDOM")

'Turn off asyncronous file loading.
objXSL.async = False

'Load the XSL file.

'Use the "transformNode" method of the XMLDOM to apply the
'XSL stylesheet to the XML document. Then the output is
'written to the client.
End Function

'The "updateXML" Function accepts one parameter.
'strXMLFile - The path and file name of the XML file.
Function updateXML(ByVal strXMLFile)

'Declare local variables.
Dim objDom
Dim objRoot
Dim objField
Dim x

'Instantiate the XMLDOM Object.
objDom = Server.CreateObject("Microsoft.XMLDOM")

'Turn off asyncronous file loading.
objDom.async = False

'Load the XML file.

'Set the objRoot variable equal to the root element of the
'XML file by calling the documentElement method of the
'objDOM (XMLDOM) object.
objRoot = objDom.documentElement

'Iterate through the Form Collection and write the
'submitted values to the XML file.
For x = 1 To Request.Form.Count

'Check see if "btn" is in the submitted value, if so,
'it is a button and should be ignored.
If InStr(1, Request.Form.Keys(x), "btn") = 0 Then

'Set objField variable equal to a field_value element by
'calling the selectSingleNode method of the objRoot
'(documentElement) object. The SelectSingleNode method
'accepts a string parameter for querying the XML document.
'In this case, the current value of the key property of
'the Form Collection is used to find the appropriate
'field_value element (more on this later).
objField = objRoot.selectSingleNode("field[@id='" & _
Request.Form.Keys(x) & "']/field_value")

'Set the text property of the objField (field_value)
'element equal to the value of the current form field.
objField.Text = Request.Form(x)
End If

'After the XML file has been edited, is must be saved.

'Release all of your object references.
objDom = Nothing
objRoot = Nothing
objField = Nothing

'Call the loadXMLFile method, passing in the newly edited
'XML file and the updatedcontact.xsl style sheet. This will
'allow the client to see the edited information. More on the
'updatedcontact.xsl file later.
loadXMLFile(strXMLFile, Server.MapPath("updatedcontact.xsl"))
End Function

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

End Sub
End Class
__________________________________________________ ________________

The error comes when i click Submit button. PLS help,Thanx in advance.
Apr 27 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.