How to Add a Header to the XML Preamble i.e "<?xml version="1.0" encoding="utf-8"?>" in xml document?

2.6k Views Asked by At

Here I wish to add a namespace to the forst line of xml document i.e

<?xml version="1.0" encoding="utf-8"?> 

I am creating the xml file using c# with the help of syndicate rss feed. it should be like

<?xml version="1.0" encoding="utf-8" xmlns:example="www.example.com ?> 
1

There are 1 best solutions below

0
On

You can use the xmlns attribute to add the namespace like

doc.DocumentElement.SetAttribute("xmlns", "www.example.com");