.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to remove namespace attribute from a xml file ?

Posted By: Sajid P K     Posted Date: October 11, 2010    Points:2   Category :C#
Hi All,

<?xml version="1.0" encoding="US-ASCII" ?>
<doc xmlns="http://rtf2xml.sourceforge.net/">
<preamble> </preamble>
<body></body>
</doc>

from above XML. How we will remove attribute xmlns="http://rtf2xml.sourceforge.net/" ?

Regards,
Sajid P K

Responses
Author: Sathakkathul Haq             
Posted Date: October 12, 2010     Points: 5   

Below code snippet is useful to remove the namespace from the xml file.

XmlDocument doc = new XmlDocument();
using (XmlTextReader reader= new XmlTextReader("C:\\Read.xml"))
{
reader.Namespaces = false;
doc.Load(reader);
}
doc.Save("C:\\Write.xml");

I hope it's useful.

with regards,
M.Sathakkathul Haq




Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend