This feed (snippit of it) needs to look exactly like this:
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
what do I add to this C# code to add that extra xmlns, xsi junk:
writer.WriteStartDocument();
writer.WriteStartElement("AmazonEnvelope");
this feed is rejected without it--
Try this:
writer.WriteStartElement("AmazonEnvelope");
writer.WriteAttributeString(
"xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString(
"xsi", "noNamespaceSchemaLocation", null, "amzn-envelope.xsd");
...
writer.WriteEndElement();
Is .NET 3.5 an option?
XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance";
string s = new XElement("AmazonEnvelope",
new XAttribute(XNamespace.Xmlns + "xsi", ns),
new XAttribute(ns + "noNamespaceSchemaLocation", "amzn-envelope.xsd")
).ToString();
or with XmlWriter
:
const string ns = "http://www.w3.org/2001/XMLSchema-instance";
writer.WriteStartDocument();
writer.WriteStartElement("AmazonEnvelope");
writer.WriteAttributeString("xmlns", "xsi", "", ns);
writer.WriteAttributeString("xsi", "noNamespaceSchemaLocation",
ns, "mzn-envelope.xsd");
writer.WriteEndDocument();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With