You can use
XmlDocument
or
XDocument
(LINQ).
It is a matter of choice, but the point is that these classes are made for creating well formatted XML structures.
This is an example using
XDocument
and
XElement
.
It will give you the output you want.
XElement xeRoot = new XElement("publication");
xeRoot.Add(new XAttribute("code", "ABC"));
xeRoot.Add(new XAttribute("uri", @"https://api.####.com/###/###"));
XElement xeName = new XElement("name");
xeRoot.Add(xeName);
XElement xeCategory = new XElement("category");
xeRoot.Add(xeCategory);
XElement xeLink = new XElement("link");
xeLink.Add(new XAttribute("rel", @"http://api-info.#########.com/v2/###/######.####"));
xeLink.Add(new XAttribute("href", @"https://api.####.com/###/###"));
xeLink.Add(new XAttribute("title", "Issue"));
xeRoot.Add(xeLink);
XDocument xDoc = new XDocument(xeRoot);
xDoc.Save("products-string.xml");