473,542 Members | 10,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Edit XML using ASP.NET

Good afternoon,

Quick and what I hope is an easy question... I have an XML file that is
holding constant values. On occasion there will be times where some of
those values will need to be updated. Is it possible to do this
programatically with ASP.NET?

As an example, a system status indicator constant is contained in the XML
file:

<SYS_STAT>No Problems to Report</SYS_STAT>

and on those hopefully rare occasions where a problem is found, the "flag"
needs to be switched to:

<SYS_STAT>Problems reported in Martin Country</SYS_STAT>

I have managed to get the file loaded, then with my total lack of knowledge
<smile> with .NET and XML, I am hitting a wall as to how to edit it. The
XML file contains upwards of 50 constants.

For arguments sake, lets call the xml file, c:\stat.xml

Many thanks in advance.
Nov 12 '05 #1
6 10946
This is terribly easy in Dot Net (shame on MS)

myDataSet.ReadXml(FileName)

' To display the entire dataset in a grid
myGrid.DataSource = myDataSet.myNodeSetName

When the document is posted back to the server:

myDataSet.WriteXML(FileName)
"Eric" <su*****@dolphinbaydesigns.com> wrote in message
news:x6********************@adelphia.com...
Good afternoon,

Quick and what I hope is an easy question... I have an XML file that is
holding constant values. On occasion there will be times where some of
those values will need to be updated. Is it possible to do this
programatically with ASP.NET?

As an example, a system status indicator constant is contained in the XML
file:

<SYS_STAT>No Problems to Report</SYS_STAT>

and on those hopefully rare occasions where a problem is found, the "flag"
needs to be switched to:

<SYS_STAT>Problems reported in Martin Country</SYS_STAT>

I have managed to get the file loaded, then with my total lack of knowledge <smile> with .NET and XML, I am hitting a wall as to how to edit it. The
XML file contains upwards of 50 constants.

For arguments sake, lets call the xml file, c:\stat.xml

Many thanks in advance.

Nov 12 '05 #2
Thank you for the response. Everything I have seen thus far on the Net has
used a datagrid. Is it possible to avoid using a user control being that
the changes to the XML are going to be system generated as opposed to user
selected?
"solex" <so***@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
This is terribly easy in Dot Net (shame on MS)

myDataSet.ReadXml(FileName)

' To display the entire dataset in a grid
myGrid.DataSource = myDataSet.myNodeSetName

When the document is posted back to the server:

myDataSet.WriteXML(FileName)
"Eric" <su*****@dolphinbaydesigns.com> wrote in message
news:x6********************@adelphia.com...
Good afternoon,

Quick and what I hope is an easy question... I have an XML file that is
holding constant values. On occasion there will be times where some of
those values will need to be updated. Is it possible to do this
programatically with ASP.NET?

As an example, a system status indicator constant is contained in the XML file:

<SYS_STAT>No Problems to Report</SYS_STAT>

and on those hopefully rare occasions where a problem is found, the "flag" needs to be switched to:

<SYS_STAT>Problems reported in Martin Country</SYS_STAT>

I have managed to get the file loaded, then with my total lack of

knowledge
<smile> with .NET and XML, I am hitting a wall as to how to edit it. The XML file contains upwards of 50 constants.

For arguments sake, lets call the xml file, c:\stat.xml

Many thanks in advance.


Nov 12 '05 #3
Not sure what you mean by "system generated" but if I may I will assume that
you mean the structure of the XML will change. If this is the case then the
Grid is the perfect tool for you because it will change automatically based
on the underlying data set (no coding needed)

If you must bind to a control other then the grid then here is a sample of
binding to a text box:

txtName.DataBindings.Add("Text", myDataSet, "myDataSet.myNodeName")

Cheers!
Dan
"Eric" <Do***********@hotmail.com> wrote in message
news:q8********************@adelphia.com...
Thank you for the response. Everything I have seen thus far on the Net has used a datagrid. Is it possible to avoid using a user control being that
the changes to the XML are going to be system generated as opposed to user
selected?
"solex" <so***@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
This is terribly easy in Dot Net (shame on MS)

myDataSet.ReadXml(FileName)

' To display the entire dataset in a grid
myGrid.DataSource = myDataSet.myNodeSetName

When the document is posted back to the server:

myDataSet.WriteXML(FileName)
"Eric" <su*****@dolphinbaydesigns.com> wrote in message
news:x6********************@adelphia.com...
Good afternoon,

Quick and what I hope is an easy question... I have an XML file that is holding constant values. On occasion there will be times where some of those values will need to be updated. Is it possible to do this
programatically with ASP.NET?

As an example, a system status indicator constant is contained in the XML file:

<SYS_STAT>No Problems to Report</SYS_STAT>

and on those hopefully rare occasions where a problem is found, the "flag" needs to be switched to:

<SYS_STAT>Problems reported in Martin Country</SYS_STAT>

I have managed to get the file loaded, then with my total lack of

knowledge
<smile> with .NET and XML, I am hitting a wall as to how to edit it. The XML file contains upwards of 50 constants.

For arguments sake, lets call the xml file, c:\stat.xml

Many thanks in advance.



Nov 12 '05 #4
I'm typing this off the top of my head, so it might be slightly wrong!

Dim xmlStat As New System.Xml.XmlDocument
xmlStat.LoadXml("c:\stat.xml")
xmlStat.SelectSingleNode("//SYS_STAT").InnerText = "Problems reported
in Martin Country"
xmlStat.Save("c:\stat.xml")

That should do it!
Chaz <
On Fri, 23 Apr 2004 16:28:18 -0400, "Eric"
<su*****@dolphinbaydesigns.com> wrote:
Good afternoon,

Quick and what I hope is an easy question... I have an XML file that is
holding constant values. On occasion there will be times where some of
those values will need to be updated. Is it possible to do this
programatically with ASP.NET?

As an example, a system status indicator constant is contained in the XML
file:

<SYS_STAT>No Problems to Report</SYS_STAT>

and on those hopefully rare occasions where a problem is found, the "flag"
needs to be switched to:

<SYS_STAT>Problems reported in Martin Country</SYS_STAT>

I have managed to get the file loaded, then with my total lack of knowledge
<smile> with .NET and XML, I am hitting a wall as to how to edit it. The
XML file contains upwards of 50 constants.

For arguments sake, lets call the xml file, c:\stat.xml

Many thanks in advance.


Nov 12 '05 #5
Keep in mind that you have to deal with concurrency issues here!

Since this is a web app, there is a chance for the following 2 situations
with 2 requests coming in at the same time:

* 1 request has the file open for writing and one or more request come in to
write the file.
* 1 request has the file open for writing and one or more requests from in
to read the file.

Inboth cases all incoming requests will FAIL to open the file. You may want
to add retry logic which means all incoming requests will appear to be
hanging until the write operation is done.

This may not be an issue if your web app has rather low usage expectations,
but for high-volume apps this can be a problem.

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Eric" <su*****@dolphinbaydesigns.com> wrote in message
news:x6********************@adelphia.com...
Good afternoon,

Quick and what I hope is an easy question... I have an XML file that is
holding constant values. On occasion there will be times where some of
those values will need to be updated. Is it possible to do this
programatically with ASP.NET?

As an example, a system status indicator constant is contained in the XML
file:

<SYS_STAT>No Problems to Report</SYS_STAT>

and on those hopefully rare occasions where a problem is found, the "flag"
needs to be switched to:

<SYS_STAT>Problems reported in Martin Country</SYS_STAT>

I have managed to get the file loaded, then with my total lack of knowledge <smile> with .NET and XML, I am hitting a wall as to how to edit it. The
XML file contains upwards of 50 constants.

For arguments sake, lets call the xml file, c:\stat.xml

Many thanks in advance.

Nov 12 '05 #6
rubik
1 New Member
And how do I set the write access to the XML file?
PLease... need help...
Jun 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6595
by: Tamir Khason | last post by:
How to prevent the selected cell from being editable (visual) at DataGrid? Once click on cell (even readonly) there are cursor inside it and select text appears. How to prevent it Thankx
0
3087
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format. However, the DataGrid begins to get very cumbersome as the number of columns of data you present increases. Anything more than half a dozen columns...
4
3703
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT>...
5
3465
by: Diane Yocom | last post by:
I'm using VS2005 and am trying to get Edit and Continue to work while debugging. I've gone to the Tools-Options-Debugging dialog box and made sure "Enable Edit and Continue" is checked, but when I start debugging and try changing the code, it just ignores any changes I've made. If I add a new line while debugging and try to step through the...
1
7279
by: Mark Stafford | last post by:
I am attempting to use a DetailsView control to view some data where the fields returned by the database are determined at runtime. I create the TemplateFields on the fly using a class that implements ITemplate and repopulate the Template properters of TemplateField in OnInit. And I am DataBinding by getting a DataTable from my db provider...
9
2709
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not...
9
7727
bhcob1
by: bhcob1 | last post by:
Hey guys, 'Update or CancelUpdate without AddNew or Edit' On my database i keep occasionly get this error when i try and edit a field, it is not everytime. It will be working fine and then this error appears. I will be editing records and then a random one will get the error. A bit of background on my form, this will seem a bit lengthy...
8
1973
by: =?Utf-8?B?bWlrZWc=?= | last post by:
Hi, I am building a small Help Desk application for my company and need to be able to edit "open" help desk issues. I use a simple datagrid to display each issue (6 per page) , with an Edit button. There are a lot of fields across, and my Network Admins would like a way of editing/updating each issue seperately in a a vertical form. I...
1
2154
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is I have Categories and various Products in each Category. I'm trying to build a page to EDIT/UPDATE each product.I want to be able to change the...
1
3304
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway (ContactGateway.cfc) - index.cfm - Deals with the business logic - display/form.cfm - Produces the form for both add and edit behaviour
0
7322
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7665
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5239
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4878
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3377
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.