C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




cut xml attribute


Posted Date: 05 Sep 2008      Total Responses: 2

Posted By: Santhosh       Member Level: Gold     Points: 1


Hi,
Iam having one xml now in my xml i want to cut one tag and in that place i want to add another tag how it possible?

<company>
<dept>
<stateOne>lp</stateOne>
<stateTwo>js</stateTwo>
</dept>
<Class>
<one>1</one>
<two>2</two>
</Class>
</company>
here i want to cut <dept> tag and i want to add <emp> tag
eg:
<company>
<emp>
<ID>123</ID>
<num>222</num>
</emp>
<Class>
<one>1</one>
<two>2</two>
</Class>
</company>




Responses

Author: varun    05 Sep 2008Member Level: GoldRating:     Points: 3
Steps:

1. Add reference to System.XML
2. Use the followingmethod:
ReplaceChild :Replaces the referenced child with a new node. If the new node is already in the tree, it is removed first.

This will replace the existing node with the new one.
For syntax, check the google.



Author: vipul    05 Sep 2008Member Level: DiamondRating:     Points: 3
hi,
used this way
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("XMLFile.xml"));

string str = xmlDoc.InnerXml;
str = str.Replace("Menu", "Menu1");
xmlDoc.LoadXml(str);
xmlDoc.Save(Server.MapPath("XMLFile.xml"));

vipul,
http://dongavipul.blogspot.com



Post Reply
You must Sign In to post a response.
Next : Install MS.Net framework using flash(Urgent)
Previous : Run time tree view image is not displaying
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use