0

I have this code for writing my XML

        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
        settings.IndentChars = ("\t");

        XmlWriter writer = XmlWriter.Create("sample.xml",settings);
        writer.WriteStartDocument();
        writer.WriteStartElement("Report", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition");
        writer.WriteAttributeString("xmlns","rd", null, "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner");
        writer.WriteEndElement();
        writer.WriteEndDocument();

        writer.Close();

The code above yields this output in my sample.xml:

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" />

However, what I would like as an output would be this:

<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

I tried re-order my codes but that didn't seem to work.

Chanchan
  • 79
  • 1
  • 8
  • 2
    According to spec, the order of xml namespace elements shouldn't matter here. Is there a functional problem? You might find support tricky because there doesn't appear to be a mandate to write them in order. – Joe Apr 27 '18 at 17:37
  • Whoa. It suddenly worked! Earlier I tried to modify the attribute of Report in my RDLC and it gave me some weird error on the RDLC Designer. Thanks mate! silly me. – Chanchan Apr 27 '18 at 17:42

0 Answers0