dandy12
09-26-2009, 05:07 PM
hello
I am new to asp.
i am following this link (http://www.xmlfiles.com/articles/michael/htmlxml/default.asp) to create a simple xml file on my server. But when i run the code it gives me "500 - Internal server error"
If i comment the last line
objDom.Save "c:\MyXMLDoc.xml", then there is no error but also the file is not created.
How can i create a simple xml file using asp???
I've tried this
objDom.Save(Server.MapPath("MyXMLDoc.xml"))
but this doesnt work either.
This is the code i am just copying/pasting (from the link above) in a simple test.asp file
<%
Dim objDom
Dim objRoot
Dim objChild1
Dim objChild2
Dim objPI
'Instantiate the XMLDOM object using the CreateObject Method of the
'Server Object.
Set objDom = Server.CreateObject("Microsoft.XMLDOM")
'Create a reference to an IXMLDOMElement (XML Element) Object by
'calling the createElement Method of the XMLDOM. The createElement
'Method accepts one paramter, a string representing the name of the
'element. The return value is passed to the objRoot variable. This
'element reference will represent the root element of the XML
'Document.
Set objRoot = objDom.createElement("rootElement")
'Use the appendChild Method of the XMLDOM Object to add the objRoot
'Element Reference to the XML Document.
objDom.appendChild objRoot
'Now, following the same steps, you will create references to the
'child elements for the XML Document. The only difference is, when the
'child elements are appended to the document, you will call the
'appendChild Method of the IXMLDOMElement Object rather than the
'appendChild Method of the XMLDOM Object. By using the IXMLDOMElement
'to append the children, you are differentiating (and applying tiered
'structure to) the child elements from the root element.
Set objChild1 = objDom.createElement("childElement1")
objRoot.appendChild objChild1
Set objChild2 = objDom.createElement("childElement2")
objRoot.appendChild objChild2
'The final step to take care of before saving this document is to add
'an XML processing instruction. This is necessary so that XML parsers
'will recognize this document as an XML document.
Set objPI = objDom.createProcessingInstruction("xml","version='1.0'")
'Call the insertBefore Method of the XMLDOM Object in order to insert
'the processing instruction before the root element (the zero element
'in the XMLDOM childNodes Collection).
objDom.insertBefore objPI, objDom.childNodes(0)
'Calling the Save Method of the XMLDOM Object will save this XML
'document to your disk drive. In this case, the document will be saved
'to the "c:" drive and will be named "MyXMLDoc.xml". When saving an
'XML document, if the file does not exist, it will be created. If it
'does exist, it will be overwritten.
objDom.Save "c:\MyXMLDoc.xml"
%>
Whats wrong. I am using Godaddy hosting.
Please help...
Regards.
I am new to asp.
i am following this link (http://www.xmlfiles.com/articles/michael/htmlxml/default.asp) to create a simple xml file on my server. But when i run the code it gives me "500 - Internal server error"
If i comment the last line
objDom.Save "c:\MyXMLDoc.xml", then there is no error but also the file is not created.
How can i create a simple xml file using asp???
I've tried this
objDom.Save(Server.MapPath("MyXMLDoc.xml"))
but this doesnt work either.
This is the code i am just copying/pasting (from the link above) in a simple test.asp file
<%
Dim objDom
Dim objRoot
Dim objChild1
Dim objChild2
Dim objPI
'Instantiate the XMLDOM object using the CreateObject Method of the
'Server Object.
Set objDom = Server.CreateObject("Microsoft.XMLDOM")
'Create a reference to an IXMLDOMElement (XML Element) Object by
'calling the createElement Method of the XMLDOM. The createElement
'Method accepts one paramter, a string representing the name of the
'element. The return value is passed to the objRoot variable. This
'element reference will represent the root element of the XML
'Document.
Set objRoot = objDom.createElement("rootElement")
'Use the appendChild Method of the XMLDOM Object to add the objRoot
'Element Reference to the XML Document.
objDom.appendChild objRoot
'Now, following the same steps, you will create references to the
'child elements for the XML Document. The only difference is, when the
'child elements are appended to the document, you will call the
'appendChild Method of the IXMLDOMElement Object rather than the
'appendChild Method of the XMLDOM Object. By using the IXMLDOMElement
'to append the children, you are differentiating (and applying tiered
'structure to) the child elements from the root element.
Set objChild1 = objDom.createElement("childElement1")
objRoot.appendChild objChild1
Set objChild2 = objDom.createElement("childElement2")
objRoot.appendChild objChild2
'The final step to take care of before saving this document is to add
'an XML processing instruction. This is necessary so that XML parsers
'will recognize this document as an XML document.
Set objPI = objDom.createProcessingInstruction("xml","version='1.0'")
'Call the insertBefore Method of the XMLDOM Object in order to insert
'the processing instruction before the root element (the zero element
'in the XMLDOM childNodes Collection).
objDom.insertBefore objPI, objDom.childNodes(0)
'Calling the Save Method of the XMLDOM Object will save this XML
'document to your disk drive. In this case, the document will be saved
'to the "c:" drive and will be named "MyXMLDoc.xml". When saving an
'XML document, if the file does not exist, it will be created. If it
'does exist, it will be overwritten.
objDom.Save "c:\MyXMLDoc.xml"
%>
Whats wrong. I am using Godaddy hosting.
Please help...
Regards.