How to modify a attribute's value of a specific node in an xml fil

Hi,

I have to modify the xml document which is present in the local disc when 
user changes the values in the form. I have to modify the attribute value of 
a specific node and then save the xml file. Please let me know how this can 
be done.

Thanks:
Rakesh
0
Rakesh (11)
6/29/2007 5:20:00 AM
dotnet.xml 7266 articles. 0 followers. Follow

7 Replies
463 Views

Similar Articles

[PageSpeed] 26

* Rakesh wrote in microsoft.public.dotnet.xml:
>I have to modify the xml document which is present in the local disc when 
>user changes the values in the form. I have to modify the attribute value of 
>a specific node and then save the xml file. Please let me know how this can 
>be done.

There are a number of ways to do this, you could use data binding, or a
data set, you can write a SAX-like filter, use .NET's pull parser, and
so on. If the XML document is small you could load it into a XmlDocument
locate and change the attribute and save it.
-- 
Bj�rn H�hrmann � mailto:bjoern@hoehrmann.de � http://bjoern.hoehrmann.de
Weinh. Str. 22 � Telefon: +49(0)621/4309674 � http://www.bjoernsworld.de
68309 Mannheim � PGP Pub. KeyID: 0xA4357E78 � http://www.websitedev.de/ 
0
bjoern1 (135)
6/29/2007 5:28:18 AM
Thanks a bunch Bjoern for the response,

Could you please let me know how can I change the attribute value once I 
load the xml file into the XML Document.

"Bjoern Hoehrmann" wrote:

> * Rakesh wrote in microsoft.public.dotnet.xml:
> >I have to modify the xml document which is present in the local disc when 
> >user changes the values in the form. I have to modify the attribute value of 
> >a specific node and then save the xml file. Please let me know how this can 
> >be done.
> 
> There are a number of ways to do this, you could use data binding, or a
> data set, you can write a SAX-like filter, use .NET's pull parser, and
> so on. If the XML document is small you could load it into a XmlDocument
> locate and change the attribute and save it.
> -- 
> Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
> Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
> 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
> 
0
Rakesh (11)
6/29/2007 7:34:02 AM
Rakesh wrote:

> Could you please let me know how can I change the attribute value once I 
> load the xml file into the XML Document.

Select the element node using SelectNodes or SelectSingleNode and simply 
call the SetAttribute method e.g.
   XmlDocument doc = new XmlDocument();
   doc.Load(@"file.xml");
   XmlElement someElement = doc.SelectSingleNode(@"root/element") as 
XmlElement;
   if (someElement != null) {
     someElement.SetAttribute("attribute-name", "new value");
     doc.Save(@"file.xml");
   }
-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
6/29/2007 11:58:35 AM
Thanks a lot Martin,

It worked !!!



"Martin Honnen" wrote:

> Rakesh wrote:
> 
> > Could you please let me know how can I change the attribute value once I 
> > load the xml file into the XML Document.
> 
> Select the element node using SelectNodes or SelectSingleNode and simply 
> call the SetAttribute method e.g.
>    XmlDocument doc = new XmlDocument();
>    doc.Load(@"file.xml");
>    XmlElement someElement = doc.SelectSingleNode(@"root/element") as 
> XmlElement;
>    if (someElement != null) {
>      someElement.SetAttribute("attribute-name", "new value");
>      doc.Save(@"file.xml");
>    }
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 
0
Rakesh (11)
6/29/2007 2:50:03 PM
Hi,

I am seeing other issue with your code. Below are the details:
The save statement is saving only that node changes and clearing all the 
existing values. This blocks me in a trouble what would be the solution for 
this...

"Rakesh" wrote:

> Thanks a lot Martin,
> 
> It worked !!!
> 
> 
> 
> "Martin Honnen" wrote:
> 
> > Rakesh wrote:
> > 
> > > Could you please let me know how can I change the attribute value once I 
> > > load the xml file into the XML Document.
> > 
> > Select the element node using SelectNodes or SelectSingleNode and simply 
> > call the SetAttribute method e.g.
> >    XmlDocument doc = new XmlDocument();
> >    doc.Load(@"file.xml");
> >    XmlElement someElement = doc.SelectSingleNode(@"root/element") as 
> > XmlElement;
> >    if (someElement != null) {
> >      someElement.SetAttribute("attribute-name", "new value");
> >      doc.Save(@"file.xml");
> >    }
> > -- 
> > 
> > 	Martin Honnen --- MVP XML
> > 	http://JavaScript.FAQTs.com/
> > 
0
Rakesh (11)
6/29/2007 6:02:07 PM
Rakesh wrote:

> I am seeing other issue with your code. Below are the details:
> The save statement is saving only that node changes and clearing all the 
> existing values. This blocks me in a trouble what would be the solution for 
> this...

I don't understand what the problem is. The Save method of an 
XmlDocument saves the complete document.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
6/30/2007 11:59:43 AM
Sorry. My bad It was due to my mistake. Code is working just fine. Thanks a 
lot...

"Martin Honnen" wrote:

> Rakesh wrote:
> 
> > I am seeing other issue with your code. Below are the details:
> > The save statement is saving only that node changes and clearing all the 
> > existing values. This blocks me in a trouble what would be the solution for 
> > this...
> 
> I don't understand what the problem is. The Save method of an 
> XmlDocument saves the complete document.
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
> 
0
Rakesh (11)
7/3/2007 7:10:02 AM
Reply:

Similar Artilces:

getting column and row names if a cell has a value
Hello, I am trying to pull data out of a large Excel spreadsheet to get a slimmed down version.. I have a large spreadsheet (100+ columns by 500+ rows, and 12 worksheets) that I'm trying to make sense of in order to import into another program. Each Column has a four-digit code for a "name", each row has a five- digit code for its "name." The majority of cells have a value of '0'. I am trying to get excel to look at the range, and if there is a value that is not zero in a cell, give me the column name in one column, the row name in the next column then the v...

Modifier Error
Whenever we try to go to modifier it gets the following error. The Modifier is currently unavailable because another user is editing resources in the Forms Dictionary. The Server has already been rebooted but we are still coming up with the same error. Thanks, Hi make sure that you are not sharing the Forms Dictionary with another users. Thanks BS "Jess M." <JessM@discussions.microsoft.com> wrote in message news:C56C6878-9410-4CF5-95DE-DCA0AC50EA55@microsoft.com... > Whenever we try to go to modifier it gets the following error. > > The Modifier is current...

EXE change in data modified
Hi Guys Have a question regarding GP. What can cause a change in the "modified date" to the dynamics.exe file? In theory, something would need to change the file. My best guess would be a service pack would change the date. -- www.fmtconsultants.com "cruesta@gmail.com" wrote: > Hi Guys > > Have a question regarding GP. What can cause a change in the "modified > date" to the dynamics.exe file? > > For GP 9.0 SP 1 the Dynamics.exe modified date is 5/16/2006 which looks to be the date the Service Pack was created (as opposed to the da...

Erroneous 'Enter Parameter Value' dialog after converting to Acc 2
After converting from access 97 to access 2000 when I try to open some of my reports from code I get an 'Enter Parameter Value' dialog appearing. There is no field name listed in the dialog and when I press the OK button the reports appears just as in Access 97. Is there any way to suppress this dialog from appearing? Answered in m.p.a.reports ...

Attributes
Our parent Business Unit is a manufacturer. Our child Business Unit is a distributor. We need some fields that pertain only to a distributor, not a manufactuerer. Is there any way besides a field level security third party add-on to add attributes and have them seen only in the business unit that added them? Hi, There is no built in feature in MS CRM to apply field level security. But it can be achived upto some extent with the help of some custome programming using CRM SDK. Something similar is shown in following URL; http://ronaldlemmen.blogspot.com/2006/04/hide-and-show-fields-based-...

Selecting a Value from a Range of Values
I want to select a value from a range of 20 Values depending upon the relationship between two cells outside that range. Lets say the Range of Values I want to select from is held in A1 to A20 I then Have a Range of Different Values in held in C1 to C24 - C1 = 1, C2 =2 ..... C24 = 24 In E1 I have a Value that could be anything from 1 to 24 If C1 = E1, I want to put the Value in A1 into D1, A2 into D2, A3 into D3 etc If C2 = E1, I want to put 0 into D1,the Value in A1 into D2, A2 into D3, A3 into D4 etc Can it be done? Simplest way would be with one formula in D1, And another in D2, wh...

extracting R-squared value from a chart
Hello, I have a scatter chart with a power trendline. The R-squared value is displayed. I did find formulae that I can use to calculate the c & b value (for the equation y=c*x^b) directly from the data. My question is whether there is a formula that I can use to either: a-extract the R-squared value from the chart, or b-calculate the R-sqared value directly from the data and equation values (c & b). I hope that makes sense. It's been a looooong time since I've used Statistics, so I may have used some terms incorrectly. If so, I apologize. Let me know a...

Problem to modify the size of PlotArea
Hello, I am trying to modify a chart so that it prints in a 20cm x 17,5cm frame. I do understand that this is governed by the plotarea.insideheight and plotarea.insidewidth properties. I also do understant that these properties are read-only. So far my code is the following: With ActiveChart .SizeWithWindow = False .PageSetup.ChartSize = xlScreenSize .PlotArea.Width = 567 .PlotArea.Height = 496 Do While .PlotArea.InsideWidth < 567 .PlotArea.Width = .Pl...

Treeview Node Uncheck Issue
Hey I'm trying to have all node checkboxes in a particular node group be unchecked if all of the child nodes are unchecked. I'm using the code below. All variables in the code are declared in the sub prior to this with code. When I run this and uncheck an item it gives me a run- time error: Run-time Error: --------------------------------------- Run-time error '91': Object variable or With block variable not set --------------------------------------- Code: ---------------------------------------------------- With Me.TreeView2 Set nod = .Nodes.Item(Node.Index).P...

changing forumla results to values on the fly
Is there a way to get a cell's forumla to convert to its resulting value on the fly (rather than having to go back in and cut>paste special>values)? Alternatively, is there a way to use a second column that will display the values returned from the formulas in the first column as hard-codes values? Thanks in advance. Click in the cell, then: <F2> <F9> -- HTH, RD --------------------------------------------------------------------------- Please keep all correspondence within the NewsGroup, so all may benefit ! ------------------------------------------------------...

VB.Net: how to carry SessionID(its value ) from 1 function to othe
If I get SessionID in 1 function how do I carry that SessionID(value of this SessionID) to another function or another form within the same project Winforms or webforms? In Winforms, u can make the SessionID a public or internal property of the form and in WebForms use the Session object to hold this value. "XML newbie: Urgent pls help!" <XMLnewbieUrgentplshelp@discussions.microsoft.com> wrote in message news:4350B554-0144-474C-893C-2269C59F75C6@microsoft.com... > If I get SessionID in 1 function how do I carry that SessionID(value of > this > SessionID) to ano...

Newbie Question : How do i add Elements into a existing XML File ?
Hi NG I got one XML File like this: <Known> <Item>Some Text 1</Item> <Item>Some Text 2</Item> <Item>Some Text 3</Item> </Known> Now i would like to add a Element <Item> with the Value 'Some Text 4' How can i add this Element without tuching the existing Elements ? Thanks for one Example regards Peter Peter Treier wrote: > <Known> > <Item>Some Text 1</Item> > <Item>Some Text 2</Item> > <Item>Some Text 3</Item> > </Known> > > Now i...

modified timeline graph
I have a table of dates and events (and "phase"), and I want to make a timeline graph: 1-d horizontal line, no (visible) y-axis. I want the distance between the events to be spaced based on the date, and the event names to be shown at each point. The dates should be shown too, either for each event or just based on auto-scaling of the x-axis (e.g. major unit = 3 months). Here's the hard part. The events happen in different "phases", and I want to show the phases graphically somehow. I was thinking this component of the graph would be a bar chart, and I could someho...

Modify name displayed in GAL
Hi all! Is there any way to change the manner in wich user are displayed in GAL? I've been aked to set DislayName to "First Last", but leave "Last First" in GAL - is there any way to do this? Thanx -- R.V. ...

modify online services
My bank recently upgraded their online services to include Direct Statements. Previously I had set up to receive Web statements. Money 2004 Omline services Manager does not give me the option to "modify services" only to "change financial institutions." Any ideas on how I can modify online banking services so I can use background banking to get Direct statements? This is how it works in M03: From account list -> Click manage online services -> click Setup online services, then select the financial institution from the list (assuming the list is updated wi...

How to count the number of values that fall within a range
8 A B C D E F G H 9 This seems to work This seems to double count those that are between and single count the rest 10 values <10 and >90 >30 and < 70 11 29.65 5.00000 28.00000 12 62.71 13 1.35 Equation in C11 14 97.13 =COUNTIF(A11:A30,"<10")+COUNTIF(A11:A30,">90")' 15 31.46 16 80.75 Equation in D11 17 8.62 =COUNTIF(A11:A30,">30")+COUNTIF(A11:A30,"<70")' 18 54.96 19 53.23 The question is, is there a similar function to counti...

Exporting from Excel to multiple XML files
Anyone know if it is possible to export multiple lines of and Excel file to multiple XML files? An example might be an Excel spreadsheet where each row is a Purchase Order (PO) complete with details of ordered items, vendor etc. This might be data exported from a database for instance. The data would be exported using an XML Schema (XML map), defined as PurchaseOrder.XSD. ...

GP7.5SP6
We're in the process of upgrading from GP7.5 SP4 to SP6. We are on MSSQL Server 7.0. My supervisor has already implemented the hot fix as describe in MBS (that's a script to update some indexes on the server if someone is using GP7.5 manufacturing on MSSQL7). When I try to import modified forms and reports I've received some errors. For instances some references on the VBA to the GUI forms (i.e. text boxes, buttons) become missing. And on the reports I've been told it couldn't find the table MOP_MO_Variance_DC_Detail_Report_Temp and MOP-Sched_Interface_Report_Before....

Search / Modify / Delete . . .
In �sheet1� I have a database with theses headers �Name, Phone, Address and below are the records rows 2-150. In �sheet2� I have the data entr� form (not VBA) its on the sheet, that has a macro that writes t �Sheet1� (for storage). How can implement a search for a record and return the result t �sheet2�, with the ability to modify or delete from the databas (�sheet1�). Thanking you in advance -- Fabl ----------------------------------------------------------------------- Fable's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=218 View this thread: http://www.ex...

Unique Values only please
Just plain brain dead ayt this point! Access XP on Win XP Query to find the unique value sets in a table. HAve approximately 5200 records in a table. One field is date, another is classname. How do I set the query to only display UNIQUE date/classname combinations. I am sure I have done thsi before, but can't remember where I found the Unique values control. Who can point me in the right direction again? Thanks On Nov 27, 5:19 pm, JR Hester <JRHes...@discussions.microsoft.com> wrote: > Just plain brain dead ayt this point! Access XP on Win XP > > Query to find the ...

Common uses for XML in an asp web application
I recently created an application that used an xml file to define 4 different groups used for my app, and within each of those groups are <item></item> tags to declare different values that were used to lookup values in a database. This worked pretty well to allow me to dynamically create navigation buttons to perform operations etc.. Now i am trying to think of other common uses for xml that would make my apps even more scalable. I think I could have used xml again in my app for this operation althought i did not because of time constraints: Once records were grabbed from the d...

Text Box values based on Combo Box value
On 'frmAllRepairs' I have two combo boxes - the first 'cboRepairCategory' determines the list for the second:- 'cboRepairType' using the following code: Private Sub cboRepairCategory_AfterUpdate() On Error Resume Next Select Case cboRepairCategory.Value Case "Grips" cboRepairType.RowSource = "tblGrips" Case "Loft and Lie" cboRepairType.RowSource = "tblLoftAndLie" Case "ReGlue" cboRepairType.RowSource = "tblReGlue"...

XML Data Type Limitations
I saw that in SQL Server 2005 the xml data has a limitation of 128 levels in the xml itself. I cannot find anything listed about this for SQL Server 2008. Is there a limitation in 2008 also? On Sun, 2 May 2010 11:55:08 -0700, "Derek Hart" <derekmhart@yahoo.com> wrote: >I saw that in SQL Server 2005 the xml data has a limitation of 128 levels in >the xml itself. I cannot find anything listed about this for SQL Server >2008. Is there a limitation in 2008 also? > The limitation still exists and you could easily prove it DECLARE @i int; DECLA...

Max Value
I have a select query that runs off a couple crosstab queries. The crosstab queries are set up with fixed columns that show Mon, Tue, Wed, Thu, Fri. I would like to add an expression field that gives me the maximum value from Mon to Fri. I can't use the Max function because the Max function can only evaluate 1 field at a time. Does anyone know a way around this or have an ideas? Below is what I tried to do to get the Max value from Mon through Fri. Max([Mon],[Tue],[Wed],[Thu],[Fri]) In a crosstab query, one field is the Row Heading, one supplies the Column Headings, and one is...

Comparing for the correct value
I have a spreadsheet were i need the computer to compare the value in cell F24, with the following values in the worksheet Basic Details in column A and then display the correct value from the B column: A B 1 >1000 �260.00 2 >1001<2000 �550.96 3 >2001<3000 �603.12 4 >3000 �0.00 One possible way =LOOKUP(F24,{1;1001;2001;3001},{260;550.96;603.12;0}) -- Regards, Peo Sjoblom "Olly" <olly854321@yahoo.co.uk> wrote in message news:28e18e8f.0311190621.57fff5aa@posting.google.com... > I have a spreadsheet were i need the computer to com...