I'm trying to set xmlns attribute, inside the Document tag, value to a custom value using XmlSerializer. At the moment my simplified xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 pain.001.001.03.xsd">
<GrpHdr>
<Price Curency="EUR">
40.55
</Price>
</GrpHdr>
</Document>
My simplified code looks like this:
public void Main(){
var document = new CustomDocument();
new XmlSerializer(typeof(CustomDocument)).Serialize(Console.Out, document);
}
[XmlRoot(ElementName = "Document")]
public class CustomDocument{
[XmlAttribute("schemaLocation", AttributeName = "schemaLocation",
Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
public string SchemaLocation = "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 pain.001.001.03.xsd";
[XmlElement("GrpHdr")
Public XmlHeader {get; set;}
Public XmlDocument(){
XmlHeader = new XmlHeader();
}
}
public class XmlHeader{
[XmlElement("Price")
Public string Price {get; set;}
public XmlHeader(){
Price = "40.55";
}
}
How can I change the value of xmlns:xsd ?Adding [XmlElement("xmlns")] doesn't do the trick