Click here to Skip to main content
15,917,061 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to rename "request" node to "my-request"

XML
<?xml version="1.0" encoding="utf-8"?>
<request>
    <user>
        <id />        
    </user>
</request>
Posted

Below is an easy solution i came up with.

XDocument xmldoc = XDocument.Load(Server.MapPath("products-2.xml"));
XElement oldXElement = xmldoc.XPathSelectElement("products/product[@id = 'p3']");
oldXElement.Name = XName.Get("test", oldXElement.Name.NamespaceName);

xmldoc.Save(Server.MapPath("products-2.xml"));
 
Share this answer
 
 
Share this answer
 
 
Share this answer
 
Comments
Espen Harlinn 11-Sep-12 10:10am    
Nice link :-D
 
Share this answer
 
Comments
Espen Harlinn 11-Sep-12 10:10am    
Nice link :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900