472,127 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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 10892
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
And how do I set the write access to the XML file?
PLease... need help...
Jun 11 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Tamir Khason | last post: by
5 posts views Thread by Diane Yocom | last post: by
9 posts views Thread by rn5a | last post: by
8 posts views Thread by =?Utf-8?B?bWlrZWc=?= | last post: by
1 post views Thread by chromis | last post: by
reply views Thread by leo001 | last post: by

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.