Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > updating with aspx and XML file

Reply
Thread Tools

updating with aspx and XML file

 
 
slinky
Guest
Posts: n/a
 
      06-11-2007
In that example where is the XML file Applicant.xml in the
downloaded...all I saw was menu.xml

On Jun 11, 3:58 pm, Alexey Smirnov <(E-Mail Removed)> wrote:
> On Jun 11, 5:40 pm, slinky <(E-Mail Removed)> wrote:
>
> > I went to the site you listed for Writing to XML... I have put
> > together a form with a textbox and a button... my code is below... I
> > simply want a user to add a record to the XML file then hit the submit
> > button, but I can seem to get the plumbing right on this one. I get
> > several errors. I've been able to do not unsimilar things with XML for
> > desktop apps (see my code at very bottom) but ASP is really throwing
> > me! Thanks for any help... struggling still....

>
> Open the example I've sent you.
>
> Where did you found a HtmlTextWriter?
>
> Change it to XMLTextWriter.
>
> Add a reference to System.XML namespace
>
> <%@ Import Namespace="System.XML" %>
>
> and add an OnClick() event
>
> <asp:Button ID="btnWriteXML" runat="server" Text="Button"
> OnClick="btnWriteXML_OnClick" />



 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-11-2007
On Jun 11, 10:19 pm, slinky <(E-Mail Removed)> wrote:
> In that example where is the XML file Applicant.xml in the
> downloaded...all I saw was menu.xml
>


Brian, it contans two files: menu.xml and XML_DEMO.aspx

XML_DEMO.aspx has an example of the code


 
Reply With Quote
 
 
 
 
slinky
Guest
Posts: n/a
 
      06-11-2007
The following error occurred: Access to the path 'E:\kunden\homepages
\26\d190091667\applicant.xml' is denied. I have the XML file in my
correct place on the tree, and I can view its contents.


On Jun 11, 4:22 pm, Alexey Smirnov <(E-Mail Removed)> wrote:
> On Jun 11, 10:19 pm, slinky <(E-Mail Removed)> wrote:
>
> > In that example where is the XML file Applicant.xml in the
> > downloaded...all I saw was menu.xml

>
> Brian, it contans two files: menu.xml and XML_DEMO.aspx
>
> XML_DEMO.aspx has an example of the code



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-11-2007
On Jun 11, 10:36 pm, slinky <(E-Mail Removed)> wrote:
> The following error occurred: Access to the path 'E:\kunden\homepages
> \26\d190091667\applicant.xml' is denied. I have the XML file in my
> correct place on the tree, and I can view its contents.


'Access to the path is denied' means that your application has no
access rights to update the file. To fix this, you can either add
write permissions to ASPNET account, or move the xml file to a
directory where you have a write access.

Hope it helps

 
Reply With Quote
 
slinky
Guest
Posts: n/a
 
      06-12-2007
How can I check the security of the XML file or change it or move it?
I can view it in a browser and can display it in the (see successful
code below) .aspx via the browser (?)
The error notes the applicant.xml file.... should I have that as
another xml file on my site in addition to menu.xml?

Again this is the sample code from the website you sent:

<%@ Page language="vb"%>
<%@ Import Namespace="System.XML" %>
<html><head>
<script language="VB" runat="server" ID=Script1>
Sub btnReadXML_OnClick(sender As Object, e As EventArgs)
'Read and display existing file
ReadXML(Server.MapPath("menu.xml"))
End Sub
Sub btnWriteXML_OnClick(sender As Object, e As EventArgs)
Try
Dim enc as Encoding
'Create file, overwrite if exists
'enc is encoding object required by constructor
'It is null, so default encoding is used
Dim objXMLTW as new XMLTextWriter(Server.MapPath("applicant.xml"),
enc)
objXMLTW.WriteStartDocument
'Top level (Parent element)
objXMLTW.WriteStartElement("Applicant")
'Child elements, from request form
objXMLTW.WriteStartElement("Name")
objXMLTW.WriteString(Request("txtName"))
objXMLTW.WriteEndElement
objXMLTW.WriteStartElement("Address")
objXMLTW.WriteString(Request("txtAddress"))
objXMLTW.WriteEndElement
objXMLTW.WriteStartElement("City")
objXMLTW.WriteString(Request("txtCity"))
objXMLTW.WriteEndElement
objXMLTW.WriteStartElement("State")
objXMLTW.WriteString(Request("txtState"))
objXMLTW.WriteEndElement
objXMLTW.WriteStartElement("Zip")
objXMLTW.WriteString(Request("txtZip"))
objXMLTW.WriteEndElement
objXMLTW.WriteEndElement 'End top level element
objXMLTW.WriteEndDocument 'End Document
objXMLTW.Flush 'Write to file
objXMLTW.Close
'Display File Just Created
ReadXML(Server.MapPath("applicant.xml"))
Catch Ex as Exception
lblXMLFile.Text = "The following error occurred: " & Ex.Message
End Try
End Sub
Sub ReadXML(FileName as String)
Try
lblXMLFile.Text =""
Dim objXMLTR as new XMLTextReader(FileName)
dim sCategory as String
dim bNested as Boolean
dim sLastElement as String
Dim sValue as String
'Read method loops through the XML stream
Do While objXMLTR.Read
'Output elements and values
'Look at output in browser and compare to menu.xml file to
'see exactly what is being done
If objXMLTR.NodeType = XMLNodeType.Element Then
if bNested = True then
if sCategory <> "" then sCategory = sCategory & " > "
sCategory = sCategory & sLastElement
End if
bNested = True
sLastElement = objXMLTR.Name
Else If objXMLTR.NodeType = XMLNodeType.Text or _
objXMLTR.NodeType = XMLNodeType.CData Then
bNested = False
sCategory = "<P>" & sCategory
sValue = objXMLTR.value
lblXMLFile.Text = lblXMLFile.Text & "<B>" & sCategory & _
"<BR>" & sLastElement & "</B><BR>" & sValue
sLastElement = ""
sCategory = ""
End if
Loop
objXMLTR.close
Catch Ex as Exception
lblXMLFile.Text = "The following error occurred: " & Ex.Message
End Try
End Sub
</script>
</head>
<body>
<center><b>XML Text Reader/Text Writer Demo</b></center>
<form method="post" action="XML_DEMO.aspx" runat="server" ID=Form1>
<table WIDTH = "100%">
<tr>
<TD width="50%" valign = top>
Click below to read/parse the file "menu.xml".<p>
<asp:Button id="btnReadXML" text="Read XML Document"
OnClick="btnReadXML_onClick" runat="server" /><p>
<asp:label id="lblXMLFile" runat="server" /></p>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="btnWriteXML_OnClick" />
</TD>
<TD width="50%" valign = top>
Complete the fields below to create and display the XML file
"applicant.xml" (write permission for the Internet Anonymous user must
be enabled)<P>
<asp:Button id="btnWriteXML" text="Write XML Document"
OnClick="btnWriteXML_onClick" runat="server" /><p><strong>Applicant</
strong>
<p><table><tr><td>
Name:</td>
<td><asp:Textbox id=txtName runat="server" width="200"
visible="True"></asp:Textbox></td></tr>
<tr><td>Address: </td>
<td>
<asp:Textbox id="txtAddress" runat="server" visible="True"
width="200"/></td></tr>
<tr><td>
City: </td>
<td>
<asp:Textbox id=txtCity runat="server" width="200"
visible="True"></asp:Textbox></td></tr>
<tr><td>
State: </td>
<td>
<asp:Textbox id=txtState runat="server" width="200" visible="True"
MaxLength="2"></asp:Textbox></td></tr>
<tr><td>
Zip: </td>
<td>
<asp:Textbox id=txtZip runat="server" width="200"
visible="True" maxlength="10"></asp:Textbox></td></tr>
</table></p>
</TD>
</tr>
</table>
</form>
</body></html>

On Jun 11, 5:05 pm, Alexey Smirnov <(E-Mail Removed)> wrote:
> On Jun 11, 10:36 pm, slinky <(E-Mail Removed)> wrote:
>
> > The following error occurred: Access to the path 'E:\kunden\homepages
> > \26\d190091667\applicant.xml' is denied. I have the XML file in my
> > correct place on the tree, and I can view its contents.

>
> 'Access to the path is denied' means that your application has no
> access rights to update the file. To fix this, you can either add
> write permissions to ASPNET account, or move the xml file to a
> directory where you have a write access.
>
> Hope it helps



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-12-2007
On Jun 12, 3:49 pm, slinky <(E-Mail Removed)> wrote:
> How can I check the security of the XML file or change it or move it?
> I can view it in a browser and can display it in the (see successful
> code below) .aspx via the browser (?)
> The error notes the applicant.xml file.... should I have that as
> another xml file on my site in addition to menu.xml?
>
> Again this is the sample code from the website you sent:


It's a matter of access rights, not a code.

"Access to the path 'E:\kunden\homepages\26\d190091667\applicant.xml'
is denied" means that ASP.NET cannot change the file located in 'E:
\kunden\homepages\26\d190091667\'. Often it's a matter of permissions
for a directory, so I think that you have no write access in the root
directory of your web site. If you have an access to the directory
properties on your server (for example with a web site management
console), then check it. If you don't - check with your web hosting
provider for questions about where you can have such access.

You can open the xml-file in the browser, or read it using a code,
because you don't need a write access for that.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating JTable Atomically - block data changes while updating. news.rcn.com Java 2 12-10-2007 11:49 AM
Newbie question about Java Updating and Inserting XML file ysongpsu@gmail.com Java 5 10-18-2007 05:38 AM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
adding main.aspx.vb & main.aspx.resx under aspx John M ASP .Net 1 05-29-2005 09:27 PM
including one aspx file in another aspx file vish ASP .Net 2 07-16-2003 10:29 PM



Advertisments